Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions http.go
Original file line number Diff line number Diff line change
Expand Up @@ -254,13 +254,18 @@ func http_get(initid *C.UDF_INIT, args *C.UDF_ARGS, result *C.char, length *uint
null_value *C.char, message *C.char) *C.char {
gArg_count := uint(args.arg_count)

// Create a new HTTP client with a timeout of 30 seconds
client := &http.Client{
Timeout: 30 * time.Second,
}

var ret string
var err error
if gArg_count == 1 {
ret, err = httpRaw("GET", C.GoString(*args.args), "", "", nil)
ret, err = httpRaw("GET", C.GoString(*args.args), "", "", nil, client)
} else {
gArgs := ((*[arrLength]*C.char)(unsafe.Pointer(args.args)))[:gArg_count:gArg_count]
ret, err = httpRaw("GET", C.GoString(*args.args), "", "", gArgs[1:])
ret, err = httpRaw("GET", C.GoString(*args.args), "", "", gArgs[1:], client)
}

if err != nil {
Expand All @@ -272,6 +277,7 @@ func http_get(initid *C.UDF_INIT, args *C.UDF_ARGS, result *C.char, length *uint
return result
}


//export http_post_init
func http_post_init(initid *C.UDF_INIT, args *C.UDF_ARGS, message *C.char) C.my_bool {
if args.arg_count < 3 {
Expand Down