GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — http.OutgoingMessage headers API · Issue #1873 · nodejs/node

http.OutgoingMessage headers API #1873

New issue
Copy link
New issue
Copy link
Closed
Closed
http.OutgoingMessage headers API#1873
Copy link
Assignees
ofrobots
Labels
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.

Description

@ChALkeR
ChALkeR
opened on Jun 2, 2015
Issue body actions

Atm, http.OutgoingMessage has the following headers-related methods:

  • .setHeader(name, value),
  • .getHeader(name, value),
  • .removeHeader(name).

There probably should be methods to:

  • Check if headers were already sent (like ._headerSent).
  • Clear all headers (if they were not already sent). — Doable with removeHeader and getHeaderNames/getHeaders since http: add new functions to OutgoingMessage #10805.
  • List all headers that were set, with values. — Landed in http: add new functions to OutgoingMessage #10805, thanks, @mscdex!

All methods that modify headers should error if the headers were already sent.

Reasoning: https://gist.github.com/ChALkeR/26573ff704f987fd5304

Activity

Next
  1. mscdex
    added
    httpIssues and PRs related to the http subsystem.
    on Jun 2, 2015
  2. Fishrock123 commented on Jun 2, 2015

    @Fishrock123
    Fishrock123
    on Jun 2, 2015
    Contributor
    More actions

    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.

  3. ChALkeR commented on Jun 2, 2015

    @ChALkeR
    ChALkeR
    on Jun 2, 2015
    MemberAuthor
    More actions

    @Fishrock123 What's the reason for making the already sent headers ungettable?

  4. Fishrock123 commented on Jun 2, 2015

    @Fishrock123
    Fishrock123
    on Jun 2, 2015
    Contributor
    More actions

    @ChALkeR I'm not sure, is that the current impl? I would say it maybe shouldn't? Honestly though, no clue.

  5. ChALkeR commented on Jun 2, 2015

    @ChALkeR
    ChALkeR
    on Jun 2, 2015
    MemberAuthor
    More actions

    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.

  6. ChALkeR commented on Jun 2, 2015

    @ChALkeR
    ChALkeR
    on Jun 2, 2015
    MemberAuthor
    More actions

    Ok, so there are no objections to adding such API methods at this moment, as I understand it.
    Correct?

  7. benjamingr commented on Jun 3, 2015

    @benjamingr
    benjamingr
    on Jun 3, 2015
    Member
    More actions

    @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.

  8. chrisdickinson commented on Jun 3, 2015

    @chrisdickinson
    chrisdickinson
    on Jun 3, 2015
    Contributor
    More actions

    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?

  9. benjamingr commented on Jun 3, 2015

    @benjamingr
    benjamingr
    on Jun 3, 2015
    Member
    More actions

    @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.

  10. ChALkeR commented on Jun 3, 2015

    @ChALkeR
    ChALkeR
    on Jun 3, 2015
    MemberAuthor
    More actions

    @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.

    Reacted by Lance Ball
  11. brendanashworth
    added
    feature requestIssues requesting new Node.js features.
    on Jun 11, 2015
  12. ChALkeR
    added
    semver-minorPRs that contain new features and should be released in the next minor version.
    on Aug 19, 2015
  13. jonathanong commented on Jan 19, 2016

    @jonathanong
    jonathanong
    on Jan 19, 2016
    Contributor
    More actions

    any node contributors have an opinion on an API? i don't mind submitting a PR if there's somewhat of a consensus

  14. ChALkeR
    added
    discussIssues opened for discussion and feedback.
    on Jan 19, 2016
  15. ChALkeR commented on Jan 19, 2016

    @ChALkeR
    ChALkeR
    on Jan 19, 2016
    MemberAuthor
    More actions

    /cc @nodejs/ctc

  16. 4 remaining items

  17. Fishrock123
    assigned
    ofrobots
    on Aug 3, 2016
  18. Fishrock123 commented on Aug 3, 2016

    @Fishrock123
    Fishrock123
    on Aug 3, 2016
    Contributor
    More actions

    @ofrobots This is (one of?) the issue(s) for headers handlng refactoring.

  19. ChALkeR commented on Feb 26, 2017

    @ChALkeR
    ChALkeR
    on Feb 26, 2017
    MemberAuthor
    More actions

    @mscdex the only remaining usecase here is «Check if headers were already sent (like ._headerSent)». Is that doable through the public API now?

  20. ChALkeR
    removed
    discussIssues opened for discussion and feedback.
    on Feb 26, 2017
  21. dougwilson commented on Feb 26, 2017

    @dougwilson
    dougwilson
    on Feb 26, 2017
    Member
    More actions

    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?

  22. ChALkeR commented on Feb 26, 2017

    @ChALkeR
    ChALkeR
    on Feb 26, 2017
    MemberAuthor
    More actions

    @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.

  23. Trott commented on Jul 27, 2017

    @Trott
    Trott
    on Jul 27, 2017
    Member
    More actions

    This should stay open, yes?

  24. ChALkeR commented on Jul 30, 2017

    @ChALkeR
    ChALkeR
    on Jul 30, 2017
    MemberAuthor
    More actions

    @Trott, yes, there are some things that I should check on this one before closing. Thanks for reminding me, though! :-)

  25. Fishrock123
    removed their assignment
    on Nov 23, 2017
  26. Fishrock123
    added
    help wantedIssues that need assistance from volunteers or PRs that need help to proceed.
    on Nov 23, 2017
  27. evanlucas commented on Feb 20, 2018

    @evanlucas
    evanlucas
    on Feb 20, 2018
    Contributor
    More actions

    @ChALkeR did you ever get around to this? Is the plan to consolidate _headerSent and headersSent?

  28. jasnell commented on Aug 11, 2018

    @jasnell
    jasnell
    on Aug 11, 2018
    Member
    More actions

    Should this remain open?

  29. jasnell
    added
    stalledIssues and PRs manually marked as stalled and scheduled for automatic closure.
    on Aug 11, 2018
  30. jasnell commented on Oct 17, 2018

    @jasnell
    jasnell
    on Oct 17, 2018
    Member
    More actions

    Closing due to lack of follow up

  31. jasnell
    closed this as completedon Oct 17, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

  • @ofrobots
    ofrobots

Labels

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.

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

    You are visitor 01402775 — GeezerVison does not store the pages you look up.
    Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.