-
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: make
OutgoingMessage
more streamlike
Implement missing getters error & closed. Add support for proper "writable" check through `isWritable` helper. We cannot fix the `OutgoingMessage.writable` property as that would break the ecosystem. PR-URL: #45672 Reviewed-By: Matteo Collina <[email protected]> Reviewed-By: Gerhard Stöbich <[email protected]> Reviewed-By: Minwoo Jung <[email protected]> Reviewed-By: Antoine du Hamel <[email protected]>
- Loading branch information
1 parent
bf6fbe2
commit 9025d6c
Showing
3 changed files
with
78 additions
and
21 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 |
---|---|---|
@@ -1,24 +1,55 @@ | ||
'use strict'; | ||
const common = require('../common'); | ||
const http = require('http'); | ||
const assert = require('assert'); | ||
|
||
const server = http.createServer(common.mustCall((req, res) => { | ||
req.pipe(res); | ||
res.on('error', common.mustNotCall()); | ||
res.on('close', common.mustCall(() => { | ||
res.end('asd'); | ||
process.nextTick(() => { | ||
server.close(); | ||
}); | ||
})); | ||
})).listen(0, () => { | ||
http | ||
.request({ | ||
port: server.address().port, | ||
method: 'PUT' | ||
}) | ||
.on('response', (res) => { | ||
res.destroy(); | ||
}) | ||
.write('asd'); | ||
}); | ||
{ | ||
const server = http.createServer(common.mustCall((req, res) => { | ||
assert.strictEqual(res.closed, false); | ||
req.pipe(res); | ||
res.on('error', common.mustNotCall()); | ||
res.on('close', common.mustCall(() => { | ||
assert.strictEqual(res.closed, true); | ||
res.end('asd'); | ||
process.nextTick(() => { | ||
server.close(); | ||
}); | ||
})); | ||
})).listen(0, () => { | ||
http | ||
.request({ | ||
port: server.address().port, | ||
method: 'PUT' | ||
}) | ||
.on('response', (res) => { | ||
res.destroy(); | ||
}) | ||
.write('asd'); | ||
}); | ||
} | ||
|
||
{ | ||
const server = http.createServer(common.mustCall((req, res) => { | ||
assert.strictEqual(res.closed, false); | ||
req.pipe(res); | ||
res.on('error', common.mustNotCall()); | ||
res.on('close', common.mustCall(() => { | ||
assert.strictEqual(res.closed, true); | ||
process.nextTick(() => { | ||
server.close(); | ||
}); | ||
})); | ||
const err = new Error('Destroy test'); | ||
res.destroy(err); | ||
assert.strictEqual(res.errored, err); | ||
})).listen(0, () => { | ||
http | ||
.request({ | ||
port: server.address().port, | ||
method: 'PUT' | ||
}) | ||
.on('error', common.mustCall()) | ||
.write('asd'); | ||
}); | ||
|
||
} |