HTTP标头解析器

时间:2014-04-20 11:15:37

标签: javascript node.js parsing http

在node.js中,当源是缓冲区/字符串时,有哪些轻量级方法可以解析HTTP头? 像使用express.js或节点的内部http模块,但没有创建实际的网络连接。

github / opensource,目前开发人员更喜欢“gist”'打字解决方案,谢谢

2 个答案:

答案 0 :(得分:1)

您可以使用节点http module内部使用的内置HTTPParser。

答案 1 :(得分:0)

您想要在不连接的情况下从请求中检索标头吗?我不确定你要做什么,但是你看看节点的核心模块'http'?

示例:

var require('http');

http.request({
    host   :   'localhost',
    port   :   8080,
    method :   'GET',
    path   :   '/endpoint'
}, function(res)
{
   res.on('end', function()
   {
       console.log('My headers: %O', res.headers);
       res.end();
   }
});