Browse Source

fixed HTTP duplicated header bug

added test case for HTTP duplicated header bug on keepalive
v0.7.4-release
Michaeljohn Clement 15 years ago
committed by Ryan Dahl
parent
commit
485823f3e4
  1. 5
      lib/http.js
  2. 21
      test/mjsunit/test-http-server.js

5
lib/http.js

@ -355,11 +355,12 @@ function createIncomingMessageStream (connection, incoming_listener) {
stream.addListener("incoming", incoming_listener);
var incoming;
var field = null, value = null;
var incoming, field, value;
connection.addListener("messageBegin", function () {
incoming = new IncomingMessage(connection);
field = null;
value = null;
});
// Only servers will get URI events.

21
test/mjsunit/test-http-server.js

@ -23,6 +23,14 @@ http.createServer(function (req, res) {
if (req.id == 1) {
assertEquals("POST", req.method);
assertEquals("/quit", req.uri.path);
}
if (req.id == 2) {
assertEquals("foo", req.headers['x-x']);
}
if (req.id == 3) {
assertEquals("bar", req.headers['x-x']);
this.close();
//puts("server closed");
}
@ -49,10 +57,17 @@ c.addListener("receive", function (chunk) {
if (requests_sent == 1) {
c.send("POST /quit HTTP/1.1\r\n\r\n");
requests_sent += 1;
}
if (requests_sent == 2) {
c.send("GET / HTTP/1.1\r\nX-X: foo\r\n\r\n"
+"GET / HTTP/1.1\r\nX-X: bar\r\n\r\n");
c.close();
assertEquals(c.readyState, "readOnly");
requests_sent += 1;
requests_sent += 2;
}
});
c.addListener("eof", function () {
@ -64,8 +79,8 @@ c.addListener("close", function () {
});
process.addListener("exit", function () {
assertEquals(2, request_number);
assertEquals(2, requests_sent);
assertEquals(4, request_number);
assertEquals(4, requests_sent);
var hello = new RegExp("/hello");
assertTrue(hello.exec(server_response) != null);

Loading…
Cancel
Save