Skip to content
This repository was archived by the owner on Nov 6, 2022. It is now read-only.

eat CRLF between requests even on connection:close #47

Closed
ry opened this issue Jun 16, 2011 · 6 comments
Closed

eat CRLF between requests even on connection:close #47

ry opened this issue Jun 16, 2011 · 6 comments

Comments

@ry
Copy link
Contributor

ry commented Jun 16, 2011

see nodejs/node-v0.x-archive#1165

we need a failing test

@bnoordhuis
Copy link
Member

Fixed if you can live with the fact that message_complete_on_eof == FALSE. The on_message_complete event fires when there is still data in the input buffer so currently_parsing_eof is FALSE at that point.

@bnoordhuis
Copy link
Member

I love how GitHub gets confused when you prune/delete branches. The commits that matter are cc58dd715b47042abd6d86783c9e4b30e816ff9b and 41ac20859fe0c7bf1b3e391edf4c16381297bc49.

@shimondoodkin
Copy link

@bnoordhuis looks like you have made some changes to code but you have not opened a pull request

@fidian
Copy link

fidian commented Apr 14, 2012

Still a problem in node 0.6.15. Here's some code that will show you what I mean. Behavior is different depending on whether or not you include the Connection: close header. GET messages also act differently than POST messages. If you make test cases, be sure to cover all four scenarios.

var port = 8001;

var server = require('http').createServer(function (req, res) {
    setTimeout(function () {
        res.writeHead(200, {'Content-Type': 'text/plain'});
        res.end("Hello World\n");
    }, 500);
}).listen(port);

console.log('Server created on port ' + port);

var client = require('net').connect(port, 'localhost', function () {
    request = "POST /post HTTP/1.1\r\n" +
        "Content-Type: application/x-www-form-urlencoded; charset=utf-8\r\n" +
        "Content-Length: 6\r\n" +
        // This line is crucial - behavior is different if you comment it out
        "Connection: close\r\n" +
        "Host: localhost\r\n" +
        "\r\n" +
        "Sample\r\n" + // Valid all through here
        "\r\n"; // This is the invalid part
    console.log('Writing request');
    client.write(request);
});

client.on('data', function (data) {
    console.log('Data:  ' + data.toString());
});

client.on('end', function () {
    console.log('End');
    server.close();
});

I only get this output:

Server created on port 8001
Writing request
End

More detailed information is available here: http-party/node-http-proxy#41

Please reopen this issue.

@bnoordhuis
Copy link
Member

@fidian: The fix for this issue was landed in c3153bd but the http-parser in node v0.6.15 is only at commit b47c44d. I've back-ported the fix in nodejs/node-v0.x-archive@d03b80b.

If you want to submit regression tests, please do so as a pull request against joyent/node.

@fidian
Copy link

fidian commented Apr 15, 2012

Sorry, I usually would check the commit hash instead of just getting the latest version, but I thought that this would have made it into node by now since the issue was closed two months ago. Sorry for the confusion.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants