标签:des blog http io os ar 使用 java for
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();
node.js http.get 和http.post 数据
标签:des blog http io os ar 使用 java for
原文地址:http://www.cnblogs.com/hubcarl/p/4066199.html