|
@ -27,6 +27,7 @@ var testIndex = 0, |
|
|
responses = 0; |
|
|
responses = 0; |
|
|
|
|
|
|
|
|
var server = http.createServer(function(req, res) { |
|
|
var server = http.createServer(function(req, res) { |
|
|
|
|
|
console.error('request', testIndex); |
|
|
switch (testIndex++) { |
|
|
switch (testIndex++) { |
|
|
case 0: |
|
|
case 0: |
|
|
res.writeHead(200, { test: 'foo \r\ninvalid: bar' }); |
|
|
res.writeHead(200, { test: 'foo \r\ninvalid: bar' }); |
|
@ -41,6 +42,7 @@ var server = http.createServer(function(req, res) { |
|
|
res.writeHead(200, { test: 'foo \n\n\ninvalid: bar' }); |
|
|
res.writeHead(200, { test: 'foo \n\n\ninvalid: bar' }); |
|
|
break; |
|
|
break; |
|
|
case 4: |
|
|
case 4: |
|
|
|
|
|
console.error('send request, then close'); |
|
|
res.writeHead(200, { test: 'foo \r\n \r\n \r\ninvalid: bar' }); |
|
|
res.writeHead(200, { test: 'foo \r\n \r\n \r\ninvalid: bar' }); |
|
|
server.close(); |
|
|
server.close(); |
|
|
break; |
|
|
break; |
|
@ -49,15 +51,16 @@ var server = http.createServer(function(req, res) { |
|
|
} |
|
|
} |
|
|
res.end('Hi mars!'); |
|
|
res.end('Hi mars!'); |
|
|
}); |
|
|
}); |
|
|
server.listen(common.PORT); |
|
|
server.listen(common.PORT, function() { |
|
|
|
|
|
|
|
|
for (var i = 0; i < 5; i++) { |
|
|
for (var i = 0; i < 5; i++) { |
|
|
var req = http.get({ port: common.PORT, path: '/' }, function(res) { |
|
|
var req = http.get({ port: common.PORT, path: '/' }, function(res) { |
|
|
assert.strictEqual(res.headers.test, 'foo invalid: bar'); |
|
|
assert.strictEqual(res.headers.test, 'foo invalid: bar'); |
|
|
assert.strictEqual(res.headers.invalid, undefined); |
|
|
assert.strictEqual(res.headers.invalid, undefined); |
|
|
responses++; |
|
|
responses++; |
|
|
|
|
|
res.resume(); |
|
|
}); |
|
|
}); |
|
|
} |
|
|
} |
|
|
|
|
|
}); |
|
|
|
|
|
|
|
|
process.on('exit', function() { |
|
|
process.on('exit', function() { |
|
|
assert.strictEqual(responses, 5); |
|
|
assert.strictEqual(responses, 5); |
|
|