这就是我认为您仅使用节点http库发出具有数据和cookie的POST请求的方式。此示例发布JSON,如果发布不同的数据,则相应地设置您的content-
type和content-length。
// NB:- node's http client API has changed since this was written// this pre is for 0.4.x// for 0.6.5+ see http://nodejs.org/docs/v0.6.5/api/http.html#http.requestvar http = require('http');var data = JSON.stringify({ 'important': 'data' });var cookie = 'something=anything'var client = http.createClient(80, 'www.example.com');var headers = { 'Host': 'www.example.com', 'cookie': cookie, 'Content-Type': 'application/json', 'Content-Length': Buffer.byteLength(data,'utf8')};var request = client.request('POST', '/', headers);// listening to the response is optional, I supposerequest.on('response', function(response) { response.on('data', function(chunk) { // do what you do }); response.on('end', function() { // do what you do });});// you'd also want to listen for errors in productionrequest.write(data);request.end();您发送的
cookie值实际上应该取决于您从服务器收到的值。Wikipedia对这些内容的撰写相当不错:http://en.wikipedia.org/wiki/HTTP_cookie#cookie_attributes



