From 3b2fab8cb35a473e27dd230b41ca493ba5ddd697 Mon Sep 17 00:00:00 2001 From: Michael Jerris Date: Thu, 17 Jul 2008 16:27:25 +0000 Subject: [PATCH] add timeout to curl run in js git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@9072 d0543943-73ff-0310-b7d9-9358b9ac24b2 --- .../mod_spidermonkey_curl/mod_spidermonkey_curl.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/mod/languages/mod_spidermonkey_curl/mod_spidermonkey_curl.c b/src/mod/languages/mod_spidermonkey_curl/mod_spidermonkey_curl.c index 3c8e8b8cef..b13090f2e8 100644 --- a/src/mod/languages/mod_spidermonkey_curl/mod_spidermonkey_curl.c +++ b/src/mod/languages/mod_spidermonkey_curl/mod_spidermonkey_curl.c @@ -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);