GeezerVison is showing github.com — http.OutgoingMessage headers API · Issue #1873 · nodejs/node
http.OutgoingMessage headers API #1873Labels feature requestIssues requesting new Node.js features.help wantedIssues that need assistance from volunteers or PRs that need help to proceed.httpIssues and PRs related to the http subsystem.stalledIssues and PRs manually marked as stalled and scheduled for automatic closure. DescriptionAtm, http.OutgoingMessage has the following headers-related methods:
.setHeader(name, value),
.getHeader(name, value),
.removeHeader(name).
There probably should be methods to:
All methods that modify headers should error if the headers were already sent.
Reasoning: https://gist.github.com/ChALkeR/26573ff704f987fd5304 ActivityFishrock123 commented on Jun 2, 2015 You may want to have a look at #772, which was originall a getAllHeaders(), but later changed focus to a getCurrentHeaders().
I didn't go through with it however, and doing it right requires re-writing far more bits of http than I was able to do. ChALkeR commented on Jun 2, 2015 @Fishrock123 What's the reason for making the already sent headers ungettable? Fishrock123 commented on Jun 2, 2015 @ChALkeR I'm not sure, is that the current impl? I would say it maybe shouldn't? Honestly though, no clue. ChALkeR commented on Jun 2, 2015 Ah, I misread #772, sorry.
Edit: No, I didn't.
Reads out all headers that are already been queued but not yet sent to the client. This can only be called before headers get implicitly flushed.
ChALkeR commented on Jun 2, 2015 Ok, so there are no objections to adding such API methods at this moment, as I understand it.
Correct? benjamingr commented on Jun 3, 2015 @ChALkeR in general, I think it would be interesting to explore that option. I think it'd be better if you suggested a concrete API we can discuss. chrisdickinson commented on Jun 3, 2015
Remove a single header (if headers were not already sent).
Isn't that covered by removeHeader?
Re: holding on to sent headers – I believe we avoid it on the grounds of not holding onto "informational" data that the user could grab earlier.
re: the reasoning: I'm not sure a list of _headers usage makes a good case for adding new APIs. What's the end goal of adding these APIs, given that we are unlikely to change _headers in the future? Would it be easier to document _headers? benjamingr commented on Jun 3, 2015 @chrisdickinson the reasoning behind putting this behind an official API is that _headers can't and doesn't warn/error if the headers were already sent which makes it a very poor API susceptible to lots of unexpected behavior.
It might be possible to change _headers to __headers and expose a _headers getter in order to keep the current API but make it safer but that might possibly break some peoples' code.
I think the point of @ChALkeR is that this is functionality people need and expect to have on OutgoingMessage and they resort to _headers because there is no standard way to do this. ChALkeR commented on Jun 3, 2015 @chrisdickinson Thanks. removeHeader is indeed already there, it was a bit late in my local time when I was writing this. Edited.
Documenting _headers would cause more havoc because it is not a fine API. A proper API for headers should check if the headers were already sent and error if the user tries to modify them after that. Or else it would be a debugging hell.
I understand that _headers are not going anywhere in the foreseeable future, but that doesn't mean that we should tell users to use that instead of implementing a proper api. jonathanong commented on Jan 19, 2016 any node contributors have an opinion on an API? i don't mind submitting a PR if there's somewhat of a consensus ChALkeR commented on Jan 19, 2016 Fishrock123 commented on Aug 3, 2016 @ofrobots This is (one of?) the issue(s) for headers handlng refactoring. ChALkeR commented on Feb 26, 2017 @mscdex the only remaining usecase here is «Check if headers were already sent (like ._headerSent)». Is that doable through the public API now? dougwilson commented on Feb 26, 2017 Though there is a slight difference in the meaning, I wonder if the existing res.headersSent getter fits the use cases people are using res._headerSent for? ChALkeR commented on Feb 26, 2017 @dougwilson Hm. It probably doesn't make sense to include two of those. I should check then why ._headerSent is used, since .headersSent is present for quite a long time. Perhaps those usages could be replaced with .headersSent (and this issue could be closed then), or perhaps there is a difference and then we should discuss what to do next. Trott commented on Jul 27, 2017 This should stay open, yes? ChALkeR commented on Jul 30, 2017 @Trott, yes, there are some things that I should check on this one before closing. Thanks for reminding me, though! :-) evanlucas commented on Feb 20, 2018 @ChALkeR did you ever get around to this? Is the plan to consolidate _headerSent and headersSent? jasnell commented on Aug 11, 2018 jasnell commented on Oct 17, 2018 Closing due to lack of follow up
MetadataMetadatafeature requestIssues requesting new Node.js features.help wantedIssues that need assistance from volunteers or PRs that need help to proceed.httpIssues and PRs related to the http subsystem.stalledIssues and PRs manually marked as stalled and scheduled for automatic closure. DevelopmentNo branches or pull requestsIssue actions
|