{"issue":{"created_at":"2011-11-30T19:54:15Z","state":"closed","updated_at":"2011-12-01T00:03:41Z","comments":1,"user":{"gravatar_id":"9017f8af999ec51ae7fe6d7b5b5fc213","id":808857,"url":"https://api.github.com/users/joeferner","avatar_url":"https://secure.gravatar.com/avatar/9017f8af999ec51ae7fe6d7b5b5fc213?d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-140.png","login":"joeferner"},"body":"I'm helping with the node_pcap project and I ran across a case where an HTTP request came in as two packets. Because of node_pcap's buffering strategy (ie reuse buffers when possible) I found a weird parsing error in the HTTPParser. If you call HTTPParser.execute using the same buffer with different data (1st packet then 2nd packet) the results are incorrect. Below is some sample code that illustrates the problem. I could fix this problem on the node_pcap side by making new buffers every time but this could severely impact performance. I tried looking through the code of the http parser in node but I'm not an expert in C.\r\n\r\nLet me know if you think this is a problem with node or a problem with how we are using your API.\r\n\r\n```javascript\r\nvar HTTPParser = process.binding('http_parser').HTTPParser;\r\n\r\nparser = new HTTPParser(HTTPParser.REQUEST);\r\nparser.onHeadersComplete = function(info) {\r\n  console.log(\"onHeadersComplete: \", info);\r\n};\r\nparser.onBody = function(buf, start, len) {\r\n  var str = buf.slice(start, len).toString();\r\n  console.log(\"onBody: \", str);\r\n};\r\nparser.onMessageComplete = function() {\r\n  console.log(\"onMessageComplete\");\r\n}\r\n\r\nvar b = new Buffer(1000);\r\n\r\nvar s = \"POST / HTTP/1.1\\r\\nUser-Agent: Mozilla\\r\\n\";\r\nb.write(s, 0, s.length);\r\nparser.execute(b, 0, s.length);\r\n\r\ns = \"Accept-Charset: utf-8, iso-8859-1, utf-16, *;q=0.7\\r\\nContent-Length: 11\\r\\n\\r\\n\";\r\nb.write(s, 0, s.length);\r\nparser.execute(b, 0, s.length);\r\n\r\ns = \"Hello World\";\r\nb.write(s, 0, s.length);\r\nparser.execute(b, 0, s.length);\r\n```\r\n\r\nI am running node v0.6.3.\r\n","assignee":null,"id":2406364,"labels":[{"name":"http","color":"e10c02","url":"https://api.github.com/repos/joyent/node/labels/http"}],"number":2235,"pull_request":{"patch_url":null,"html_url":null,"diff_url":null},"title":"HTTPParser called with same buffer causes parsing error of the headers.","html_url":"https://github.com/joyent/node/issues/2235","closed_at":"2011-12-01T00:03:41Z","url":"https://api.github.com/repos/joyent/node/issues/2235","milestone":null},"action":"closed"}