Skip to content

Commit 3e40337

Browse files
committed
syntax cleanup
1 parent 64cdb5c commit 3e40337

1 file changed

Lines changed: 13 additions & 12 deletions

File tree

src/targets/c/libcurl.js

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

88
code.push('CURL *hnd = curl_easy_init();')
9-
code.push('')
10-
11-
code.push('curl_easy_setopt(hnd, CURLOPT_CUSTOMREQUEST, "%s");', source.method.toUpperCase())
12-
code.push('curl_easy_setopt(hnd, CURLOPT_URL, "%s");', source.fullUrl)
9+
.blank()
10+
.push('curl_easy_setopt(hnd, CURLOPT_CUSTOMREQUEST, "%s");', source.method.toUpperCase())
11+
.push('curl_easy_setopt(hnd, CURLOPT_URL, "%s");', source.fullUrl)
1312

1413
// Add headers, including the cookies
1514
var headers = Object.keys(source.headersObj)
1615

1716
// construct headers
1817
if (headers.length) {
19-
code.push('')
20-
code.push('struct curl_slist *headers = NULL;')
18+
code.blank()
19+
.push('struct curl_slist *headers = NULL;')
20+
2121
headers.map(function (key) {
2222
code.push('headers = curl_slist_append(headers, "%s: %s");', key, source.headersObj[key])
2323
})
24+
2425
code.push('curl_easy_setopt(hnd, CURLOPT_HTTPHEADER, headers);')
2526
}
2627

2728
// construct cookies
2829
if (source.allHeaders.cookie) {
29-
code.push('')
30-
code.push('curl_easy_setopt(hnd, CURLOPT_COOKIE, "%s");', source.allHeaders.cookie)
30+
code.blank()
31+
.push('curl_easy_setopt(hnd, CURLOPT_COOKIE, "%s");', source.allHeaders.cookie)
3132
}
3233

3334
if (source.postData.text) {
34-
code.push('')
35-
code.push('curl_easy_setopt(hnd, CURLOPT_POSTFIELDS, %s);', JSON.stringify(source.postData.text))
35+
code.blank()
36+
.push('curl_easy_setopt(hnd, CURLOPT_POSTFIELDS, %s);', JSON.stringify(source.postData.text))
3637
}
3738

38-
code.push('')
39-
code.push('CURLcode ret = curl_easy_perform(hnd);')
39+
code.blank()
40+
.push('CURLcode ret = curl_easy_perform(hnd);')
4041

4142
return code.join()
4243
}

0 commit comments

Comments
 (0)