-
Notifications
You must be signed in to change notification settings - Fork 29.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
http: align OutgoingMessage and ClientRequest destroy
Added .destroyed property to OutgoingMessage and ClientRequest to align with streams. Fixed ClientRequest.destroy to dump res and re-use socket in agent pool aligning it with abort. PR-URL: #32148 Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: Matteo Collina <[email protected]>
- Loading branch information
Showing
7 changed files
with
155 additions
and
38 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
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,71 @@ | ||
'use strict'; | ||
const common = require('../common'); | ||
const http = require('http'); | ||
const assert = require('assert'); | ||
|
||
{ | ||
// abort | ||
|
||
const server = http.createServer(common.mustCall((req, res) => { | ||
res.end('Hello'); | ||
})); | ||
|
||
server.listen(0, common.mustCall(() => { | ||
const options = { port: server.address().port }; | ||
const req = http.get(options, common.mustCall((res) => { | ||
res.on('data', (data) => { | ||
req.abort(); | ||
assert.strictEqual(req.aborted, true); | ||
assert.strictEqual(req.destroyed, true); | ||
server.close(); | ||
}); | ||
})); | ||
req.on('error', common.mustNotCall()); | ||
assert.strictEqual(req.aborted, false); | ||
assert.strictEqual(req.destroyed, false); | ||
})); | ||
} | ||
|
||
{ | ||
// destroy + res | ||
|
||
const server = http.createServer(common.mustCall((req, res) => { | ||
res.end('Hello'); | ||
})); | ||
|
||
server.listen(0, common.mustCall(() => { | ||
const options = { port: server.address().port }; | ||
const req = http.get(options, common.mustCall((res) => { | ||
res.on('data', (data) => { | ||
req.destroy(); | ||
assert.strictEqual(req.aborted, false); | ||
assert.strictEqual(req.destroyed, true); | ||
server.close(); | ||
}); | ||
})); | ||
req.on('error', common.mustNotCall()); | ||
assert.strictEqual(req.aborted, false); | ||
assert.strictEqual(req.destroyed, false); | ||
})); | ||
} | ||
|
||
{ | ||
// destroy | ||
|
||
const server = http.createServer(common.mustNotCall((req, res) => { | ||
})); | ||
|
||
server.listen(0, common.mustCall(() => { | ||
const options = { port: server.address().port }; | ||
const req = http.get(options, common.mustNotCall()); | ||
req.on('error', common.mustCall((err) => { | ||
assert.strictEqual(err.code, 'ECONNRESET'); | ||
server.close(); | ||
})); | ||
assert.strictEqual(req.aborted, false); | ||
assert.strictEqual(req.destroyed, false); | ||
req.destroy(); | ||
assert.strictEqual(req.aborted, false); | ||
assert.strictEqual(req.destroyed, true); | ||
})); | ||
} |
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