Skip to content

Commit

Permalink
few input checks
Browse files Browse the repository at this point in the history
  • Loading branch information
caffix committed May 9, 2023
1 parent bc4c126 commit 4e99688
Showing 1 changed file with 14 additions and 12 deletions.
26 changes: 14 additions & 12 deletions datasrcs/scripting/http.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,13 @@ func (s *Script) request(L *lua.LState) int {
}

var hdr http.Header
lv := L.GetField(opt, "header")
if tbl, ok := lv.(*lua.LTable); ok {
hdr = make(http.Header)
tbl.ForEach(func(k, v lua.LValue) {
hdr[k.String()] = v.String()
})
if lv := L.GetField(opt, "header"); lv != nil {
if tbl, ok := lv.(*lua.LTable); ok {
hdr = make(http.Header)
tbl.ForEach(func(k, v lua.LValue) {
hdr[k.String()] = v.String()
})
}
}

var body string
Expand Down Expand Up @@ -145,12 +146,13 @@ func (s *Script) scrape(L *lua.LState) int {
}

var hdr http.Header
lv := L.GetField(opt, "header")
if tbl, ok := lv.(*lua.LTable); ok {
hdr = make(http.Header)
tbl.ForEach(func(k, v lua.LValue) {
hdr[k.String()] = v.String()
})
if lv := L.GetField(opt, "header"); lv != nil {
if tbl, ok := lv.(*lua.LTable); ok {
hdr = make(http.Header)
tbl.ForEach(func(k, v lua.LValue) {
hdr[k.String()] = v.String()
})
}
}

var body string
Expand Down

0 comments on commit 4e99688

Please sign in to comment.