|
39 | 39 | - [Simple Request - Async / Await](#simple-request---async--await)
|
40 | 40 | - [Simple Request](#simple-request)
|
41 | 41 | - [Setting HTTP headers](#setting-http-headers)
|
42 |
| - - [MultiPart Upload / HttpPost libcurl Option](#multipart-upload--httppost-libcurl-option) |
| 42 | + - [Form Submission (Content-Type: application/x-www-form-urlencoded)](#form-submission-content-type-applicationx-www-form-urlencoded) |
| 43 | + - [MultiPart Upload / HttpPost libcurl Option (Content-Type: multipart/form-data)](#multipart-upload--httppost-libcurl-option-content-type-multipartform-data) |
43 | 44 | - [Benchmarks](#benchmarks)
|
44 | 45 | - [API](#api)
|
| 46 | +- [Common Issues](#common-issues) |
45 | 47 | - [Supported Libcurl Versions](#supported-libcurl-versions)
|
46 | 48 | - [For Enterprise](#for-enterprise)
|
47 | 49 | - [Detailed Installation](#detailed-installation)
|
@@ -77,6 +79,19 @@ const { curly } = require('node-libcurl');
|
77 | 79 | const { statusCode, data, headers } = await curly.get('http://www.google.com')
|
78 | 80 | ```
|
79 | 81 |
|
| 82 | +Any option can be passed using their `FULLNAME` or a `lowerPascalCase` format: |
| 83 | +```javascript |
| 84 | +const querystring = require('querystring'); |
| 85 | +const { curly } = require('node-libcurl'); |
| 86 | + |
| 87 | +const { statusCode, data, headers } = await curly.post('http://httpbin.com/post', { |
| 88 | + postFields: querystring.stringify({ |
| 89 | + field: 'value', |
| 90 | + }), |
| 91 | + // can use `postFields` or `POSTFIELDS` |
| 92 | +}) |
| 93 | +``` |
| 94 | + |
80 | 95 | ### Simple Request
|
81 | 96 | ```javascript
|
82 | 97 | const { Curl } = require('node-libcurl');
|
@@ -108,7 +123,25 @@ curl.setOpt(Curl.option.HTTPHEADER,
|
108 | 123 | ['Content-Type: application/x-amz-json-1.1'])
|
109 | 124 | ```
|
110 | 125 |
|
111 |
| -### MultiPart Upload / HttpPost libcurl Option |
| 126 | +### Form Submission (Content-Type: application/x-www-form-urlencoded) |
| 127 | +```javascript |
| 128 | +const querystring = require('querystring'); |
| 129 | +const { Curl } = require('node-libcurl'); |
| 130 | + |
| 131 | +const curl = new Curl(); |
| 132 | +const close = curl.close.bind(curl); |
| 133 | + |
| 134 | +curl.setOpt(Curl.option.URL, '127.0.0.1/upload'); |
| 135 | +curl.setOpt(Curl.option.POST, true) |
| 136 | +curl.setOpt(Curl.option.POSTFIELDS, querystring.stringify({ |
| 137 | + field: 'value', |
| 138 | +})); |
| 139 | + |
| 140 | +curl.on('end', close); |
| 141 | +curl.on('error', close); |
| 142 | +``` |
| 143 | + |
| 144 | +### MultiPart Upload / HttpPost libcurl Option (Content-Type: multipart/form-data) |
112 | 145 |
|
113 | 146 | ```javascript
|
114 | 147 | const { Curl } = require('node-libcurl');
|
@@ -139,6 +172,10 @@ Almost all [CURL options](https://curl.haxx.se/libcurl/c/curl_easy_setopt.html)
|
139 | 172 |
|
140 | 173 | For more usage examples check the [examples folder](./examples).
|
141 | 174 |
|
| 175 | +## Common Issues |
| 176 | + |
| 177 | +See [COMMON_ISSUES.md](./COMMON_ISSUES.md) |
| 178 | + |
142 | 179 | ## Supported Libcurl Versions
|
143 | 180 |
|
144 | 181 | The addon is only tested against libcurl version `7.50.0` and the latest one available.
|
|
0 commit comments