http.get('http://codestudy.sinaapp.com', function (response) {});

node.js http post 样例:
var reqData={ id:'111' }; var post_options = { host: '127.0.0.1' port: '8888', path: '/api/list', method: 'POST', headers: { 'Content-Type': 'application/x-www-form-urlencoded', 'Content-Length': reqData.length } }; var post_req = http.request(post_options, function (response) { var responseText=[]; var size = 0; response.on('data', function (data) { responseText.push(data); size+=data.length; }); response.on('end', function () { // Buffer 是node.js 自带的库,直接使用 responseText = Buffer.concat(responseText,size); callback(responseText); }); }); // post the data post_req.write(reqData); post_req.end();

  

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2021-07-09
  • 2022-12-23
  • 2022-12-23
  • 2021-05-03
  • 2021-11-29
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2021-10-26
  • 2022-12-23
  • 2021-08-14
  • 2021-11-08
  • 2022-12-23
  • 2021-12-31
相关资源
相似解决方案