-
Notifications
You must be signed in to change notification settings - Fork 29.9k
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
Process 100, 102-199 status codes according to specs. #18033
Closed
Closed
Changes from 18 commits
Commits
Show all changes
20 commits
Select commit
Hold shift + click to select a range
5200fab
Process 100, 102-199 status codes according to specs.
miles-po fba79a8
Cleaning up status code comment to be clearer.
miles-po 58bb0ca
Cleaning up code to reuse informational status check.
miles-po 79301fa
Fine tuning comment change.
miles-po b2c81fc
Renamed 'informational' function to be more explicit.
miles-po fd33e98
Firing event for information messages
miles-po 2113f0a
Adding writeInformation to handle 1xx status codes
miles-po 65405c4
Adding 102 Processing test
miles-po ea72928
Renaming 102 status test
miles-po 29cae69
Added test for 103 Early Hints
miles-po 5f4049c
Making a record
miles-po d7bacbb
Dropped 103+ and concentrated on 102 Processing
miles-po 12e0566
Capitalized comment and added comments for context
miles-po e51c7ae
Addressing notes by @mcollina
miles-po 0386a11
Updated docs to clarify and show usage
miles-po e46b997
Fixed line length
miles-po 130e729
Removed HTTP/2 doc updates
miles-po 89e4552
Fixed rebase errors and nits
miles-po 1eee678
Unwrapped redundant mustCall(...)
miles-po 1c2e86d
Fixed markdown typo; removed warning
miles-po 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 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,52 @@ | ||
'use strict'; | ||
const common = require('../common'); | ||
const assert = require('assert'); | ||
const http = require('http'); | ||
const Countdown = require('../common/countdown'); | ||
|
||
const test_res_body = 'other stuff!\n'; | ||
const countdown = new Countdown(3, common.mustCall(() => server.close())); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done |
||
|
||
const server = http.createServer((req, res) => { | ||
console.error('Server sending informational message #1...'); | ||
res.writeProcessing(); | ||
console.error('Server sending informational message #2...'); | ||
res.writeProcessing(); | ||
console.error('Server sending full response...'); | ||
res.writeHead(200, { | ||
'Content-Type': 'text/plain', | ||
'ABCD': '1' | ||
}); | ||
res.end(test_res_body); | ||
}); | ||
|
||
server.listen(0, function() { | ||
const req = http.request({ | ||
port: this.address().port, | ||
path: '/world' | ||
}); | ||
req.end(); | ||
console.error('Client sending request...'); | ||
|
||
let body = ''; | ||
|
||
req.on('information', function(res) { | ||
console.error('Client got 102 Processing...'); | ||
countdown.dec(); | ||
}); | ||
|
||
req.on('response', function(res) { | ||
assert.strictEqual(countdown.remaining, 1, | ||
'Full response received before all 102 Processing'); | ||
assert.strictEqual(200, res.statusCode, | ||
`Final status code was ${res.statusCode}, not 200.`); | ||
res.setEncoding('utf8'); | ||
res.on('data', function(chunk) { body += chunk; }); | ||
res.on('end', function() { | ||
console.error('Got full response.'); | ||
assert.strictEqual(body, test_res_body); | ||
assert.ok('abcd' in res.headers); | ||
countdown.dec(); | ||
}); | ||
}); | ||
}); |
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This change should also be added to the http2 compat API
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should also explain why 101 Upgrade is not included in this
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, good spot.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also an example illustrating what "This event is emitted with a object" means would be helpful.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Quick question: Should 101s actually fire the event too?
I excluded 101 Upgrade since this was typically used to make TLS upgrades (rare) or Web Socket connections (typical). I don't work on the Socket.IO project—for example—so I don't know the potential drawbacks. I suppose performance wouldn't suffer measurably just from firing an event with no listeners.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I take that back. 101 Upgrade messages are handled so differently, they can break the request/response model dramatically. Web Sockets being a prime example but TLS as well. Leaving as is.