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:
Michael Jerris 2008-07-17 16:27:25 +00:00
parent 50b827f8f6
commit 3b2fab8cb3

View File

@ -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);