From: Anthony Minessale Date: Tue, 26 Aug 2008 18:38:02 +0000 (+0000) Subject: add optional content-type arg X-Git-Tag: v1.0.2~1374 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=860b4c34469e756d3aca7c110e45428eb2b0dbdf;p=thirdparty%2Ffreeswitch.git add optional content-type arg git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@9368 d0543943-73ff-0310-b7d9-9358b9ac24b2 --- 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 b13090f2e8..17a772360c 100644 --- a/src/mod/languages/mod_spidermonkey_curl/mod_spidermonkey_curl.c +++ b/src/mod/languages/mod_spidermonkey_curl/mod_spidermonkey_curl.c @@ -113,6 +113,7 @@ static JSBool curl_run(JSContext * cx, JSObject * obj, uintN argc, jsval * argv, long httpRes = 0; struct curl_slist *headers = NULL; int32 timeout = 0; + char ct[80] = "Content-Type: application/x-www-form-urlencoded"; if (argc < 2 || !co) { return JS_FALSE; @@ -122,12 +123,17 @@ static JSBool curl_run(JSContext * cx, JSObject * obj, uintN argc, jsval * argv, method = JS_GetStringBytes(JS_ValueToString(cx, argv[0])); url = JS_GetStringBytes(JS_ValueToString(cx, argv[1])); + if (argc > 2) { + char *content_type = JS_GetStringBytes(JS_ValueToString(cx, argv[2])); + snprintf(ct, sizeof(ct), "Content-Type: %s", content_type); + } + co->curl_handle = curl_easy_init(); if (!strncasecmp(url, "https", 5)) { curl_easy_setopt(co->curl_handle, CURLOPT_SSL_VERIFYPEER, 0); curl_easy_setopt(co->curl_handle, CURLOPT_SSL_VERIFYHOST, 0); } - headers = curl_slist_append(headers, "Content-Type: application/x-www-form-urlencoded"); + headers = curl_slist_append(headers, ct); if (argc > 2) { data = JS_GetStringBytes(JS_ValueToString(cx, argv[2]));