Skip to content

Commit 64cdb5c

Browse files
author
Shashi Ranjan
committed
added spacing
1 parent bad12d3 commit 64cdb5c

14 files changed

Lines changed: 49 additions & 0 deletions

File tree

src/targets/c/libcurl.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ module.exports = function (source, options) {
66
var code = new CodeBuilder()
77

88
code.push('CURL *hnd = curl_easy_init();')
9+
code.push('')
10+
911
code.push('curl_easy_setopt(hnd, CURLOPT_CUSTOMREQUEST, "%s");', source.method.toUpperCase())
1012
code.push('curl_easy_setopt(hnd, CURLOPT_URL, "%s");', source.fullUrl)
1113

@@ -14,6 +16,7 @@ module.exports = function (source, options) {
1416

1517
// construct headers
1618
if (headers.length) {
19+
code.push('')
1720
code.push('struct curl_slist *headers = NULL;')
1821
headers.map(function (key) {
1922
code.push('headers = curl_slist_append(headers, "%s: %s");', key, source.headersObj[key])
@@ -23,13 +26,16 @@ module.exports = function (source, options) {
2326

2427
// construct cookies
2528
if (source.allHeaders.cookie) {
29+
code.push('')
2630
code.push('curl_easy_setopt(hnd, CURLOPT_COOKIE, "%s");', source.allHeaders.cookie)
2731
}
2832

2933
if (source.postData.text) {
34+
code.push('')
3035
code.push('curl_easy_setopt(hnd, CURLOPT_POSTFIELDS, %s);', JSON.stringify(source.postData.text))
3136
}
3237

38+
code.push('')
3339
code.push('CURLcode ret = curl_easy_perform(hnd);')
3440

3541
return code.join()
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,12 @@
11
CURL *hnd = curl_easy_init();
2+
23
curl_easy_setopt(hnd, CURLOPT_CUSTOMREQUEST, "POST");
34
curl_easy_setopt(hnd, CURLOPT_URL, "http://mockbin.com/har");
5+
46
struct curl_slist *headers = NULL;
57
headers = curl_slist_append(headers, "content-type: application/x-www-form-urlencoded");
68
curl_easy_setopt(hnd, CURLOPT_HTTPHEADER, headers);
9+
710
curl_easy_setopt(hnd, CURLOPT_POSTFIELDS, "foo=bar&hello=world");
11+
812
CURLcode ret = curl_easy_perform(hnd);
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,12 @@
11
CURL *hnd = curl_easy_init();
2+
23
curl_easy_setopt(hnd, CURLOPT_CUSTOMREQUEST, "POST");
34
curl_easy_setopt(hnd, CURLOPT_URL, "http://mockbin.com/har");
5+
46
struct curl_slist *headers = NULL;
57
headers = curl_slist_append(headers, "content-type: application/json");
68
curl_easy_setopt(hnd, CURLOPT_HTTPHEADER, headers);
9+
710
curl_easy_setopt(hnd, CURLOPT_POSTFIELDS, "{\"number\":1,\"string\":\"f\\\"oo\",\"arr\":[1,2,3],\"nested\":{\"a\":\"b\"},\"arr_mix\":[1,\"a\",{\"arr_mix_nested\":{}}]}");
11+
812
CURLcode ret = curl_easy_perform(hnd);
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
CURL *hnd = curl_easy_init();
2+
23
curl_easy_setopt(hnd, CURLOPT_CUSTOMREQUEST, "POST");
34
curl_easy_setopt(hnd, CURLOPT_URL, "http://mockbin.com/har");
5+
46
curl_easy_setopt(hnd, CURLOPT_COOKIE, "foo=bar; bar=baz");
7+
58
CURLcode ret = curl_easy_perform(hnd);
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
CURL *hnd = curl_easy_init();
2+
23
curl_easy_setopt(hnd, CURLOPT_CUSTOMREQUEST, "PROPFIND");
34
curl_easy_setopt(hnd, CURLOPT_URL, "http://mockbin.com/har");
5+
46
CURLcode ret = curl_easy_perform(hnd);
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,15 @@
11
CURL *hnd = curl_easy_init();
2+
23
curl_easy_setopt(hnd, CURLOPT_CUSTOMREQUEST, "POST");
34
curl_easy_setopt(hnd, CURLOPT_URL, "http://mockbin.com/har?foo=bar&foo=baz&baz=abc&key=value");
5+
46
struct curl_slist *headers = NULL;
57
headers = curl_slist_append(headers, "content-type: application/x-www-form-urlencoded");
68
headers = curl_slist_append(headers, "accept: application/json");
79
curl_easy_setopt(hnd, CURLOPT_HTTPHEADER, headers);
10+
811
curl_easy_setopt(hnd, CURLOPT_COOKIE, "foo=bar; bar=baz");
12+
913
curl_easy_setopt(hnd, CURLOPT_POSTFIELDS, "foo=bar");
14+
1015
CURLcode ret = curl_easy_perform(hnd);
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
11
CURL *hnd = curl_easy_init();
2+
23
curl_easy_setopt(hnd, CURLOPT_CUSTOMREQUEST, "GET");
34
curl_easy_setopt(hnd, CURLOPT_URL, "http://mockbin.com/har");
5+
46
struct curl_slist *headers = NULL;
57
headers = curl_slist_append(headers, "x-foo: Bar");
68
headers = curl_slist_append(headers, "accept: application/json");
79
curl_easy_setopt(hnd, CURLOPT_HTTPHEADER, headers);
10+
811
CURLcode ret = curl_easy_perform(hnd);
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
CURL *hnd = curl_easy_init();
2+
23
curl_easy_setopt(hnd, CURLOPT_CUSTOMREQUEST, "GET");
34
curl_easy_setopt(hnd, CURLOPT_URL, "https://mockbin.com/har");
5+
46
CURLcode ret = curl_easy_perform(hnd);
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,12 @@
11
CURL *hnd = curl_easy_init();
2+
23
curl_easy_setopt(hnd, CURLOPT_CUSTOMREQUEST, "POST");
34
curl_easy_setopt(hnd, CURLOPT_URL, "http://mockbin.com/har");
5+
46
struct curl_slist *headers = NULL;
57
headers = curl_slist_append(headers, "content-type: multipart/form-data; boundary=---011000010111000001101001");
68
curl_easy_setopt(hnd, CURLOPT_HTTPHEADER, headers);
9+
710
curl_easy_setopt(hnd, CURLOPT_POSTFIELDS, "-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"foo\"; filename=\"hello.txt\"\r\nContent-Type: text/plain\r\n\r\nHello World\r\n-----011000010111000001101001--");
11+
812
CURLcode ret = curl_easy_perform(hnd);
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,12 @@
11
CURL *hnd = curl_easy_init();
2+
23
curl_easy_setopt(hnd, CURLOPT_CUSTOMREQUEST, "POST");
34
curl_easy_setopt(hnd, CURLOPT_URL, "http://mockbin.com/har");
5+
46
struct curl_slist *headers = NULL;
57
headers = curl_slist_append(headers, "content-type: multipart/form-data; boundary=---011000010111000001101001");
68
curl_easy_setopt(hnd, CURLOPT_HTTPHEADER, headers);
9+
710
curl_easy_setopt(hnd, CURLOPT_POSTFIELDS, "-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"foo\"; filename=\"hello.txt\"\r\nContent-Type: text/plain\r\n\r\n\r\n-----011000010111000001101001--");
11+
812
CURLcode ret = curl_easy_perform(hnd);

0 commit comments

Comments
 (0)