-
Notifications
You must be signed in to change notification settings - Fork 30k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This change makes it possible for userland http-related modules to pave over edge cases that require referencing the original request when handling a response--making a "Lodash for HTTP" library possible. More information and research in #28673 Fixes: #28673 PR-URL: #36505 Reviewed-By: Robert Nagy <[email protected]>
- Loading branch information
1 parent
4ae3135
commit fc3f1c3
Showing
6 changed files
with
65 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
'use strict'; | ||
|
||
const common = require('../common'); | ||
if (!common.hasCrypto) | ||
common.skip('missing crypto'); | ||
const assert = require('assert'); | ||
const h2 = require('http2'); | ||
|
||
// Http2ServerResponse should expose convenience properties | ||
|
||
const server = h2.createServer(); | ||
server.listen(0, common.mustCall(function() { | ||
const port = server.address().port; | ||
server.once('request', common.mustCall(function(request, response) { | ||
assert.strictEqual(response.req, request); | ||
|
||
response.on('finish', common.mustCall(function() { | ||
process.nextTick(() => { | ||
server.close(); | ||
}); | ||
})); | ||
response.end(); | ||
})); | ||
|
||
const url = `http://localhost:${port}`; | ||
const client = h2.connect(url, common.mustCall(function() { | ||
const headers = { | ||
':path': '/foobar', | ||
':method': 'GET', | ||
':scheme': 'http', | ||
':authority': `localhost:${port}` | ||
}; | ||
const request = client.request(headers); | ||
request.on('end', common.mustCall(function() { | ||
client.close(); | ||
})); | ||
request.end(); | ||
request.resume(); | ||
})); | ||
})); |