Parse Error on http.get in 0.4.11 #1569

Closed
dscape opened this Issue Aug 21, 2011 · 9 comments

3 participants

@dscape

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

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

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

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

@koichik

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.

@bnoordhuis
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.

Thoughts?

@koichik

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

@bnoordhuis
Node.js Foundation member

That one's probably worth picking too.

@koichik

LGTM. +1

@koichik

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

@dscape

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.
8b2a335
@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.
5724b54
@bnoordhuis
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