Tag: content length

在NodeJS中发送POST请求时如何设置Content-Length?

var https = require('https'); var p = '/api/username/FA/AA?ZOHO_ACTION=EXPORT&ZOHO_OUTPUT_FORMAT=JSON&ZOHO_ERROR_FORMAT=JSON&ZOHO_API_KEY=dummy1234&ticket=dummy9876&ZOHO_API_VERSION=1.0'; var https = require('https'); var options = { host: 'reportsapi.zoho.com', port: 443, path: p, method: 'POST' }; var req = https.request(options, function(res) { console.log("statusCode: ", res.statusCode); console.log("headers: ", res.headers); res.on('data', function(d) { process.stdout.write(d); }); }); req.end(); req.on('error', function(e) { console.error(e); }); 当我运行上面的代码,我得到以下错误。 错误信息: statusCode: 411 headers: { […]