Node.js http.ClientRequest:获取原始头 [英] Node.js http.ClientRequest: get raw headers
问题描述
我使用Node.js 0.2.3和response.headers ['set-cookie']似乎在第一个cookie后被截断。
I am using Node.js 0.2.3 and response.headers['set-cookie'] seems to be truncated after the first cookie. Is there any way I can just read the raw headers?
BTW,set-cookie标头应该包含:
BTW, the set-cookie header should contain:
id1=sw34rwdsfsd;secure;
id2=wer235sd2354;secure;
id3=df435df4543;secure
我的猜测是它不是解析布尔属性并在第一个之后停止。任何人都知道这是在Node.js的更高版本中修复的(即使我还无法升级)?
My guess would be it is not parsing the boolean attributes right and stops after the first one. Anyone know if this is fixed in later versions of Node.js (even though I can't upgrade just yet)?
推荐答案
var spawn = require('child_process').spawn;
function getHeader(url, callback){
var client = spawn('curl', ['-I', url]);
client.stdout.setEncoding('***');
client.stdout.on('data', function(data){
callback(data);
});
}
-I标志只询问标题的curl。传递任何编码到setEncoding - 我认为它默认为你正在寻找的原始。
The -I flag asks curl for just the header. Pass whatever encoding to setEncoding - I think it defaults to the raw that you're looking for.
这篇关于Node.js http.ClientRequest:获取原始头的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!