-
-
Notifications
You must be signed in to change notification settings - Fork 34.2k
http: add http.ClientRequest.getRawHeaderNames() #37660
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
Conversation
aduh95
left a comment
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.
Could you add documentation please?
|
This looks like a good start - documentation and a test would be the next steps :) |
|
@aduh95, @benjamingr, I updated the deprecation message, and added docs for the @benjamingr there is a test in |
That sounds reasonable - if you'd like I think there is value in adding a few more cases there - otherwise the test you added is probably fine for now and we can add more tests in a future PR. |
benjamingr
left a comment
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.
Generally LGTM, ping @nodejs/http
|
@benjamingr I added one additional assertion for testing the new method on the response object. |
lib/_http_outgoing.js
Outdated
| const headers = Array(ObjectKeys(headersMap).length); | ||
|
|
||
| if (headersMap !== null) { | ||
| const values = ObjectValues(headersMap); |
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.
Can we avoid calling %Object.keys% here? We can get the same info from %Object.values%, right? Also, if headersMap is null, wouldn't %Object.keys% throw?
| const headers = Array(ObjectKeys(headersMap).length); | |
| if (headersMap !== null) { | |
| const values = ObjectValues(headersMap); | |
| if (headerMap == null) return []; | |
| const values = ObjectValues(headersMap); | |
| const headers = Array(values.length); | |
| { |
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.
We can also save the length to a variable to reuse it in the for loop.
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.
Good call, pushed 👍
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 missed the length comment, but I can add that if needed?
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.
Btw values.length is stored in l so that's only one assignment + accessing the property added.
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 think we can either:
- store the value in a variable and read the variable to avoid looking up the property value several time.
- access the property each time and rely on the compiler optimisations.
The current implementation access the property twice before putting its value in a variable, that seems unnecessary.
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.
The current implementation access the property twice before putting its value in a variable, that seems unnecessary.
Exactly. Not sure if one additional property access call on top changes anything, but I can update the code if you want. Your call.
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.
Yes, I'd prefer to see either of the approach described in my comment above.
mcollina
left a comment
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
This comment has been minimized.
This comment has been minimized.
ecb76b9 to
b99d01f
Compare
Fixes: nodejs#37641 PR-URL: nodejs#37660 Reviewed-By: Matteo Collina <[email protected]> Reviewed-By: Benjamin Gruenbaum <[email protected]> Reviewed-By: Rich Trott <[email protected]>
b99d01f to
4686cb5
Compare
|
Landed in 4686cb5 Thanks for reporting the issue and doing the work to fix it! 🎉 |
Fixes: #37641
As discussed here #37641 (comment) I'm submitting a patch to expose the raw header names being sent with the request.
I didn't updated the documentation because I'm not sure about the process for deprecating things since DEP0066 was introduced in v12 and this is v15.