-
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.
http: makes response.writeHead return the response
Fixes: #25935 PR-URL: #25974 Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: Luigi Pinca <[email protected]>
- Loading branch information
Showing
3 changed files
with
37 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
22 changes: 22 additions & 0 deletions
22
test/parallel/test-http-response-writehead-returns-this.js
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,22 @@ | ||
'use strict'; | ||
require('../common'); | ||
const http = require('http'); | ||
const assert = require('assert'); | ||
|
||
const server = http.createServer((req, res) => { | ||
res.writeHead(200, { 'a-header': 'a-header-value' }).end('abc'); | ||
}); | ||
|
||
server.listen(0, () => { | ||
http.get({ port: server.address().port }, (res) => { | ||
assert.strictEqual(res.headers['a-header'], 'a-header-value'); | ||
|
||
const chunks = []; | ||
|
||
res.on('data', (chunk) => chunks.push(chunk)); | ||
res.on('end', () => { | ||
assert.strictEqual(Buffer.concat(chunks).toString(), 'abc'); | ||
server.close(); | ||
}); | ||
}); | ||
}); |