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