Skip to content
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

make response headers more directly consumable with node-fetch #7168

Closed
wants to merge 1 commit into from

Conversation

calebcartwright
Copy link
Member

Resolves #7167

@calebcartwright calebcartwright added core Server, BaseService, GitHub auth needs-discussion A consensus is needed to move forward labels Oct 17, 2021
@shields-ci
Copy link

Messages
📖 ✨ Thanks for your contribution to Shields, @calebcartwright!

Generated by 🚫 dangerJS against 5b6ac2b

Comment on lines +90 to +103
const headers = Array.from(resp.headers.entries()).reduce(
(headers, [name, value]) => {
headers[name] = value
return headers
},
{}
)
return {
res: {
...resp,
headers,
},
buffer: body,
}
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably worth parking for a bit and considering what, if any, potential impact this could have given that it'd currently occur on each and every request even though the vast majority of service classes don't really care about the response headers.

IIRC within v8 an Array.from is a by reference shallow copy so wouldn't expect that piece to necessitate any additional allocations/cpy's, though not opposed to instantiating the headers object upfront and then just using a .forEach( over the entries to insert the pairs.

Another option would be to only conditionally map the response headers if it's explicitly requested by the service class

@chris48s chris48s mentioned this pull request Oct 19, 2021
@calebcartwright
Copy link
Member Author

Closing in favor of #7175

@calebcartwright calebcartwright deleted the node-fetch-response-headers branch November 13, 2021 17:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
core Server, BaseService, GitHub auth needs-discussion A consensus is needed to move forward
Projects
None yet
Development

Successfully merging this pull request may close these issues.

node-fetch response headers "missing" due to API difference
3 participants