-
Notifications
You must be signed in to change notification settings - Fork 29.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
`flushHeaders` should work for header written with `writeHead`. PR-URL: #1695 Reviewed-By: Ben Noordhuis <[email protected]>
- Loading branch information
1 parent
4e90c82
commit 2c686fd
Showing
3 changed files
with
31 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
'use strict'; | ||
const common = require('../common'); | ||
const assert = require('assert'); | ||
const http = require('http'); | ||
|
||
const server = http.createServer(); | ||
|
||
server.on('request', function(req, res) { | ||
res.writeHead(200, {'foo': 'bar'}); | ||
res.flushHeaders(); | ||
res.flushHeaders(); // Should be idempotent. | ||
}); | ||
server.listen(common.PORT, common.localhostIPv4, function() { | ||
var req = http.request({ | ||
method: 'GET', | ||
host: common.localhostIPv4, | ||
port: common.PORT, | ||
}, onResponse); | ||
|
||
req.end(); | ||
|
||
function onResponse(res) { | ||
assert.equal(res.headers['foo'], 'bar'); | ||
res.destroy(); | ||
server.close(); | ||
} | ||
}); |