[Freeswitch-svn] [commit] r9368 - freeswitch/trunk/src/mod/languages/mod_spidermonkey_curl

Freeswitch SVN anthm at freeswitch.org
Tue Aug 26 14:38:03 EDT 2008


Author: anthm
Date: Tue Aug 26 14:38:02 2008
New Revision: 9368

Modified:
   freeswitch/trunk/src/mod/languages/mod_spidermonkey_curl/mod_spidermonkey_curl.c

Log:
add optional content-type arg

Modified: freeswitch/trunk/src/mod/languages/mod_spidermonkey_curl/mod_spidermonkey_curl.c
==============================================================================
--- freeswitch/trunk/src/mod/languages/mod_spidermonkey_curl/mod_spidermonkey_curl.c	(original)
+++ freeswitch/trunk/src/mod/languages/mod_spidermonkey_curl/mod_spidermonkey_curl.c	Tue Aug 26 14:38:02 2008
@@ -113,6 +113,7 @@
 	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 @@
 	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]));



More information about the Freeswitch-svn mailing list