mirror of
https://github.com/signalwire/freeswitch.git
synced 2025-04-14 16:15:04 +00:00
add timeout to curl run in js
git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@9072 d0543943-73ff-0310-b7d9-9358b9ac24b2
This commit is contained in:
parent
50b827f8f6
commit
3b2fab8cb3
@ -112,6 +112,7 @@ static JSBool curl_run(JSContext * cx, JSObject * obj, uintN argc, jsval * argv,
|
||||
char *url_p = NULL, *data = NULL, *durl = NULL;
|
||||
long httpRes = 0;
|
||||
struct curl_slist *headers = NULL;
|
||||
int32 timeout = 0;
|
||||
|
||||
if (argc < 2 || !co) {
|
||||
return JS_FALSE;
|
||||
@ -148,6 +149,14 @@ static JSBool curl_run(JSContext * cx, JSObject * obj, uintN argc, jsval * argv,
|
||||
}
|
||||
}
|
||||
|
||||
if (argc > 6) {
|
||||
JS_ValueToInt32(cx, argv[6], &timeout);
|
||||
if (timeout > 0) {
|
||||
curl_easy_setopt(co->curl_handle, CURLOPT_TIMEOUT, timeout);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
curl_easy_setopt(co->curl_handle, CURLOPT_HTTPHEADER, headers);
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user