]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
add timeout to curl run in js
authorMichael Jerris <mike@jerris.com>
Thu, 17 Jul 2008 16:27:25 +0000 (16:27 +0000)
committerMichael Jerris <mike@jerris.com>
Thu, 17 Jul 2008 16:27:25 +0000 (16:27 +0000)
git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@9072 d0543943-73ff-0310-b7d9-9358b9ac24b2

src/mod/languages/mod_spidermonkey_curl/mod_spidermonkey_curl.c

index 3c8e8b8cefaf5c72c78a42b7fddf5af4c31447f3..b13090f2e8a8d9d2d14ce9abca577e739b2e6f91 100644 (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);