Skip to content Skip to sidebar Skip to footer

Http Message On Node.js

I'm a total noob in node.js (and internet tech. in general). On my assignment from the uni. in which we were asked to develop an http server, I have been requested to do the follow

Solution 1:

Node itself uses a http_parser written in C.

It's based on NGINX's HTTP parser with some extensions by the node core team.

Node's http module then [uses it](var HTTPParser = process.binding('http_parser').HTTPParser;)

var HTTPParser = process.binding('http_parser').HTTPParser;

For example the ClientRequest::onSocket uses a parser.

ClientRequest.prototype.onSocket = function(socket) {
  var req = this;
  process.nextTick(function() {
    var parser = parsers.alloc();
    // [snip]
  });
};

If you actually want to write your own parser then have fun parsing the HTTP protocol.

If you don't know how to write a parser, then read up on Parsing


Post a Comment for "Http Message On Node.js"