mirror of
https://github.com/signalwire/freeswitch.git
synced 2025-03-14 04:54:49 +00:00
add optional content-type arg
git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@9368 d0543943-73ff-0310-b7d9-9358b9ac24b2
This commit is contained in:
parent
e4dd67c6cc
commit
860b4c3446
@ -113,6 +113,7 @@ static JSBool curl_run(JSContext * cx, JSObject * obj, uintN argc, jsval * argv,
|
|||||||
long httpRes = 0;
|
long httpRes = 0;
|
||||||
struct curl_slist *headers = NULL;
|
struct curl_slist *headers = NULL;
|
||||||
int32 timeout = 0;
|
int32 timeout = 0;
|
||||||
|
char ct[80] = "Content-Type: application/x-www-form-urlencoded";
|
||||||
|
|
||||||
if (argc < 2 || !co) {
|
if (argc < 2 || !co) {
|
||||||
return JS_FALSE;
|
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]));
|
method = JS_GetStringBytes(JS_ValueToString(cx, argv[0]));
|
||||||
url = JS_GetStringBytes(JS_ValueToString(cx, argv[1]));
|
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();
|
co->curl_handle = curl_easy_init();
|
||||||
if (!strncasecmp(url, "https", 5)) {
|
if (!strncasecmp(url, "https", 5)) {
|
||||||
curl_easy_setopt(co->curl_handle, CURLOPT_SSL_VERIFYPEER, 0);
|
curl_easy_setopt(co->curl_handle, CURLOPT_SSL_VERIFYPEER, 0);
|
||||||
curl_easy_setopt(co->curl_handle, CURLOPT_SSL_VERIFYHOST, 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) {
|
if (argc > 2) {
|
||||||
data = JS_GetStringBytes(JS_ValueToString(cx, argv[2]));
|
data = JS_GetStringBytes(JS_ValueToString(cx, argv[2]));
|
||||||
|
Loading…
x
Reference in New Issue
Block a user