Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

fixed HTTP duplicated header bug

added test case for HTTP duplicated header bug on keepalive
  • Loading branch information...
commit 485823f3e44013c4c83fcbbabd3a234f680ebb3c 1 parent 5b1a535
@inimino inimino authored ry committed
Showing with 21 additions and 5 deletions.
  1. +3 −2 lib/http.js
  2. +18 −3 test/mjsunit/test-http-server.js
View
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.
View
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);
Please sign in to comment.
Something went wrong with that request. Please try again.