-
Notifications
You must be signed in to change notification settings - Fork 29.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
http: added aborted property to request
Backport-PR-URL: #22850 PR-URL: #20094 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
- Loading branch information
1 parent
98ed30f
commit 1edd7f6
Showing
8 changed files
with
89 additions
and
2 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
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,26 @@ | ||
'use strict'; | ||
|
||
const common = require('../common'); | ||
const http = require('http'); | ||
const assert = require('assert'); | ||
|
||
const server = http.createServer(common.mustCall(function(req, res) { | ||
req.on('aborted', common.mustCall(function() { | ||
assert.strictEqual(this.aborted, true); | ||
server.close(); | ||
})); | ||
assert.strictEqual(req.aborted, false); | ||
res.write('hello'); | ||
})); | ||
|
||
server.listen(0, common.mustCall(() => { | ||
const req = http.get({ | ||
port: server.address().port, | ||
headers: { connection: 'keep-alive' } | ||
}, common.mustCall((res) => { | ||
res.on('aborted', common.mustCall(() => { | ||
assert.strictEqual(res.aborted, true); | ||
})); | ||
req.abort(); | ||
})); | ||
})); |
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'); | ||
if (!common.hasCrypto) | ||
common.skip('missing crypto'); | ||
const h2 = require('http2'); | ||
const assert = require('assert'); | ||
|
||
|
||
const server = h2.createServer(common.mustCall(function(req, res) { | ||
req.on('aborted', common.mustCall(function() { | ||
assert.strictEqual(this.aborted, true); | ||
})); | ||
assert.strictEqual(req.aborted, false); | ||
res.write('hello'); | ||
server.close(); | ||
})); | ||
|
||
server.listen(0, common.mustCall(function() { | ||
const url = `http://localhost:${server.address().port}`; | ||
const client = h2.connect(url, common.mustCall(() => { | ||
const request = client.request(); | ||
request.on('data', common.mustCall((chunk) => { | ||
client.destroy(); | ||
})); | ||
})); | ||
})); |