-
Notifications
You must be signed in to change notification settings - Fork 630
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
feat(node/http): minor HTTP Server/Response improvements #1448
Conversation
…lose()` method, refactor `ServerResponse`
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.
Some overlap with #1435, would be best to merge both improvements.
@talentlessguy could you please combine changes from #1435 in your PR? I would also be great to have some tests covering the changes, especially for all those header methods. |
@talentlessguy Do you mind if I push http changes from #1435 to this branch ? (or maybe it's best to just land this and cherrypick the #1435 changes in another PR) Note that class field initializers absolutely murder performance, given the importance of the HTTP-stack hot paths, we're quite sensitive to this. An improvement has been landed in v8 (https://chromium.googlesource.com/v8/v8/+/713ebae3b4ef42d00220097ab2f238ffe8e4b87e), I haven't tested it yet, I don't think it closes the entire gap, ideally we should fix this upstream in v8 instead of working around it. |
@AaronO yeah it's completely fine |
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.
LGTM
Note: field initializers are atrociously slow, but there are improvements coming in v8 9.7, so we'll punt on them until testing them
Co-authored-by: Aaron O'Mullan <aaron.omullan@gmail.com>
This PR adds a few improvements (sorry that multiple changes in one PR, I was just fixing a lot of stuff at the same time)
ref: https://nodejs.org/api/http.html
Server
EventEmitter
and hasclose
andconnection
eventsclose()
method which triggerslistener.close()
ServerResponse
statusCode
andstatusMessage
propertiesHeaders
API instead of a string to string record for headers managementremoveHeader
,getHeaderNames
,hasHeader
ensureHeaders
is a private method now because it's not defined in Node.js HTTP docssetHeader
now returns response object for chaining (as defined in Node.js HTTP docs)