How to set Content-Length when sending POST request in NodeJS?

后端 未结 4 722
甜味超标
甜味超标 2021-02-08 13:17
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&         


        
4条回答
  •  说谎
    说谎 (楼主)
    2021-02-08 14:16

    var server = http.createServer();
    server.on('request', function(req, res) {
    
        req.on('data',function(data){
    
            res.writeHead(200, {'Content-Type': 'text/plain','Content-Length':data.toString().length+''});
            res.write(data.toString());
            res.end();
        });  
    
    });
    

提交回复
热议问题