node.js package for parsing http-like protocols
npm install httplike
var Parser = require('httplike');
var p = new Parser(socket);
p.on('message', function(msg) {
console.log(msg.method);
console.log(msg.headers);
console.log(msg.content);
});
httplike
assumes that the incoming protocol follows HTTP standards on using the Content-Length header to determine how many bytes to wait for in a response body.
- Fixed parsing involving UTF-8 characters (PR #8), and potential stall in pipelined requests (PR #9)
- Removed
parseHeader
from public interface onClientParser
andServerParser
- Removed dependency on
lodash
- Implemented built-in response object modeled after express.js response.
- Added
trim()
to method and headers
- Breaking changes to how headers are accessed (
getHeader()
function instead ofheaders[]
). See tests for example usage.