HyperText Transfer Protocol Partial Parser
HTTPPP lets you parse only the bits of HTTP that you really need. It is designed specifically to aid in the creation of proxies that need to be fast and support arbitrary HTTP-like protocols. It doesn't mess with the actual data being pushed through the connection, so it trivially supports websockets and other extensions that rely on upgrade functionality or similar.
Available via npm:
$ npm install httppp
Or via git:
$ git clone git://github.com/deoxxa/httppp.git node_modules/httppp
module.exports value (the thing you get when you
is a factory function for creating parsers.
var parser = ;
#headerson the new
Parserobject. See below for information on the
Constructs a new httppp Parser object, optionally supplying some configuration information as an object.
// basic instantiationvar parser = ;// instantiation with optionsvar parser = maximumHeaderBytes: 4096;
maximumHeaderBytes, which controls how many bytes the parser will try to read before it gives up and emits an error saying that the headers were too long.
The "headers" event is emitted when httppp has decided that it's parsed all the headers that are going to arrive. Note that this is only emitted once per connection, with the implication of that being that you won't know about pipelined requests.
The payload for the event is an object with properties of
path are both strings, and
headers is an object,
where the keys are the header names, and the values are arrays containing the
values collected for that header. The values are arrays because multiple headers
with the same name may be sent (for example cookies).
NOTE: the payload for this event used to be an array, and to maintain
compatibility with code that's still expecting that, the properties of the
payload are aliased as
You might want to look at example.js as well.
var net =http =httppp = ;var server1_port = nullserver2_port = null;var proxy = net;proxy;var server1 = http;server1;var server2 = http;server2;
3-clause BSD. A copy is included with the source.