-
Notifications
You must be signed in to change notification settings - Fork 29.8k
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
getHeader() returns undefined after using writeHead() in a certain circumstance #10354
Comments
Oh haha, one of these "bug"s. Related to #1873 IIRC there are a number of performance reason this is difficult to fix because? Implicit headers... stuff? Maybe when it's null we can just assign it to that object... |
Seems when |
@DevAndrewGeorge I think (but I have not checked) that it should be possible to invoke the same mechanism as However it should be mentioned that you are still missing implicit headers and... I think you can still get poorly defined behavior when mixing That being said I'd review a PR if you are willing to make one that covers what I've mentioned in the first paragraph. :D |
@nodejs/http |
A reasonable explanation to this behavior is optimization as opposed to a bug. This block explains the logic. The same is also explained in #13825 (comment) and a PR is being worked upon here : #19902 |
@Fishrock123 - can we have a consensus on this as to:
My assertion is that use |
Not a bug, an optimization. Could maybe use a note in the docs. If we want uniform behavior, we could set |
thanks. Added |
I should actually block away a few hours and actually get this done. It's been literal years.... :P |
calling writeHead() into a Response object that has no headers already set causes getHeader() to return undefined, even if the header was set in the writeHead() function call. Explain this behavior as an optimiation as opposed to a bug. Fixes: nodejs#10354
calling writeHead() into a Response object that has no headers already set causes getHeader() to return undefined, even if the header was set in the writeHead() function call. Explain this behavior as an optimiation as opposed to a bug. Fixes: #10354 PR-URL: #21289 Reviewed-By: Anatoli Papirovski <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Luigi Pinca <[email protected]> Reviewed-By: Timothy Gu <[email protected]> Reviewed-By: Vse Mozhet Byt <[email protected]> Reviewed-By: Trivikram Kamat <[email protected]>
In short, calling
writeHead()
with aServerResponse
object which has no headers already set causesgetHeader()
to returnundefined
even if the header was set in thewriteHead()
function call. I am unfamiliar with the project, so I'm unsure if this is defined behavior or not.The text was updated successfully, but these errors were encountered: