Parse Error on http.get in 0.4.11 #1569

dscape opened this Issue Aug 21, 2011 · 9 comments

3 participants


You get a parse error on this very simple request.
Works on 0.5+

http = require('http');
var options = {
  host: '',
  port: 80,
  path: '/bugreport/d481d73b6e78ed07c405293ee80be4a6/IMG_20110517_093510-1.jpeg'

http.get(options, function(res) {
}).on('error', function(e) {
  console.log("Got error: " + e.message);
Node.js Foundation member

I can confirm that it works with master but fails with v0.4.


The response has Content-Type header that value includes \n

Content-Type: image/jpeg;\n x-unix-mode=0600;\n name="IMG_20110517_093510-1.jpeg"

This was fixed upstream and merged into master (c3ccbea), but not yet v0.4.

Node.js Foundation member

I suspected it was that.

We can't easily upgrade the HTTP parser in v0.4. It breaks four tests and the fixes may require API changes (big no no for the v0.4 branch).

Cherry-picking ry/http-parser@b89f944 works okay, all tests pass and it fixes the issue. The commit itself is side effect free and it's not an API change either so it seems like the way forward. A standalone test would be nice to have though.



There is only one commit between current v0.4 (ry/http-parser@eee6012) and ry/http-parser@b89f944.

Node.js Foundation member

That one's probably worth picking too.


LGTM. +1


@ry - Can you merge ry/http-parser@3258e4a and ry/http-parser@b89f944 to v0.4 branch?


In case someone is experiencing the same problem with CouchDB the following work-around exists. CouchDB doesn't enforce newlines, this is coming from your environment when you push the attachment. CouchDB simply respects the fact that you inserted newlines in your Content-Type and preserves it.

To solve it simply remove new line chars from Content-Type.

@bnoordhuis bnoordhuis added a commit that closed this issue Sep 14, 2011
@bnoordhuis bnoordhuis http_parser: cherry-pick 3258e4a and b89f944 from upstream
Fixes #1569, parse error on multi-line HTTP headers.
@bnoordhuis bnoordhuis added a commit that referenced this issue Sep 14, 2011
@bnoordhuis bnoordhuis test: add http multi-line header test
Test case for #1569. Verify that http_parser parses multi-line headers.
Node.js Foundation member

Fixed in 8b2a335, test added in 5724b54.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment