Skip to content

Expose response headers which are currently set. #3421

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Closed
JvJefke opened this issue Sep 21, 2017 · 3 comments
Closed

Expose response headers which are currently set. #3421

JvJefke opened this issue Sep 21, 2017 · 3 comments
Assignees
Labels

Comments

@JvJefke
Copy link

JvJefke commented Sep 21, 2017

I have a use case where I need a list of all currently set headers. This is possible with the unofficial res._headers property. It would be great if there would be an official way to get this information.

Maybe the response object could be extended with this:
res.getHeaders();

This would then return a copy of the currently set headers.

Does this seem like a good idea?

@dougwilson
Copy link
Contributor

@dougwilson dougwilson self-assigned this Sep 21, 2017
@JvJefke
Copy link
Author

JvJefke commented Sep 21, 2017

Oh ok. I didn't know that.
Sadly we are stuck with supporting 4.x.x and up so this is not a solution for us.
I can however make our implementation future proof by checking the availability of this new function before using res._headers.

Thx for the quick response!

@dougwilson
Copy link
Contributor

Yea, we don't shadow or shim APIs in Express.js, just the additional sugar that is needed. nodejs/node#10805 is the PR in Node.js and it's been requested to be backported to Node.js 6.x multiple times, I think you can request it be backported to 4.x as well, though.

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants