-
-
Notifications
You must be signed in to change notification settings - Fork 31.9k
http: add writeEarlyHints function to ServerResponse #44180
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
nodejs-github-bot
merged 6 commits into
nodejs:main
from
wingleung:add-writeEarlyHints-function
Aug 17, 2022
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
3f31f7b
http: add writeEarlyHints function to ServerResponse
35ea4b9
add better regex pattern to match rfc8288 specs
961a8a5
http2: add writeEarlyHints to http2
e9d0be0
Update lib/internal/validators.js
wingleung 82dea4c
http: tweak regex
c204024
add writeEarlyHints to http2 docs
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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
33 changes: 33 additions & 0 deletions
33
test/parallel/test-http-early-hints-invalid-argument-type.js
This file contains hidden or 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,33 @@ | ||
'use strict'; | ||
const common = require('../common'); | ||
const assert = require('node:assert'); | ||
const http = require('node:http'); | ||
const debug = require('node:util').debuglog('test'); | ||
|
||
const testResBody = 'response content\n'; | ||
|
||
const server = http.createServer(common.mustCall((req, res) => { | ||
debug('Server sending early hints...'); | ||
res.writeEarlyHints({ links: 'bad argument object' }); | ||
|
||
debug('Server sending full response...'); | ||
res.end(testResBody); | ||
})); | ||
|
||
server.listen(0, common.mustCall(() => { | ||
const req = http.request({ | ||
port: server.address().port, path: '/' | ||
}); | ||
|
||
req.end(); | ||
debug('Client sending request...'); | ||
|
||
req.on('information', common.mustNotCall()); | ||
|
||
process.on('uncaughtException', (err) => { | ||
debug(`Caught an exception: ${JSON.stringify(err)}`); | ||
if (err.name === 'AssertionError') throw err; | ||
assert.strictEqual(err.code, 'ERR_INVALID_ARG_VALUE'); | ||
process.exit(0); | ||
}); | ||
})); |
This file contains hidden or 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,33 @@ | ||
'use strict'; | ||
const common = require('../common'); | ||
const assert = require('node:assert'); | ||
const http = require('node:http'); | ||
const debug = require('node:util').debuglog('test'); | ||
|
||
const testResBody = 'response content\n'; | ||
|
||
const server = http.createServer(common.mustCall((req, res) => { | ||
debug('Server sending early hints...'); | ||
res.writeEarlyHints('bad argument value'); | ||
|
||
debug('Server sending full response...'); | ||
res.end(testResBody); | ||
})); | ||
|
||
server.listen(0, common.mustCall(() => { | ||
const req = http.request({ | ||
port: server.address().port, path: '/' | ||
}); | ||
|
||
req.end(); | ||
debug('Client sending request...'); | ||
|
||
req.on('information', common.mustNotCall()); | ||
|
||
process.on('uncaughtException', (err) => { | ||
debug(`Caught an exception: ${JSON.stringify(err)}`); | ||
if (err.name === 'AssertionError') throw err; | ||
assert.strictEqual(err.code, 'ERR_INVALID_ARG_VALUE'); | ||
process.exit(0); | ||
}); | ||
})); |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.