https://github.com/jiangmiao/node-curl/blob/master/examples/low-level.js
解决方法
CURLOPT_POST
A parameter set to 1 tells the library to do a regular HTTP post. This will also make the library use a “Content-Type: application/x-www-form-urlencoded” header. (This is by far the most commonly used POST method).
Use one of CURLOPT_POSTFIELDS or CURLOPT_copYPOSTFIELDS options to specify what data to post and CURLOPT_POSTFIELDSIZE or CURLOPT_POSTFIELDSIZE_LARGE to set the data size.
Optionally,you can provide data to POST using the CURLOPT_READFUNCTION and CURLOPT_READDATA options but then you must make sure to not set CURLOPT_POSTFIELDS to anything but NULL. When providing data with a callback,you must transmit it using chunked transfer-encoding or you must set the size of the data with the CURLOPT_POSTFIELDSIZE or CURLOPT_POSTFIELDSIZE_LARGE option. To enable chunked encoding,you simply pass in the appropriate transfer-encoding header,see the post-callback.c example.
CURLOPT_POSTFIELDS
… [this] should be the full data to post in a HTTP POST operation. You must make sure that the data is formatted the way you want the server to receive it. libcurl will not convert or encode it for you. Most web servers will assume this data to be url-encoded.
This POST is a normal application/x-www-form-urlencoded kind (and libcurl will set that Content-Type by default when this option is used),which is the most commonly used one by HTML forms. See also the CURLOPT_POST. Using CURLOPT_POSTFIELDS implies CURLOPT_POST.
If you want to do a zero-byte POST,you need to set CURLOPT_POSTFIELDSIZE explicitly to zero,as simply setting CURLOPT_POSTFIELDS to NULL or “” just effectively disables the sending of the specified string. libcurl will instead assume that you’ll send the POST data using the read callback!
有了这些信息,您应该能够将以下选项添加到低级示例中,以使其发出POST请求:
var fieldsstr = '{}'; curl.setopt('CURLOPT_POST',1); // true? curl.setopt('CURLOPT_POSTFIELDS',fieldsstr);
您需要调整fieldsstr的内容以匹配服务器所期望的格式.根据文档,您可能还需要对数据进行url编码 – 这应该像根据this post使用encodeURIComponent一样简单.