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

feat: Deno.createHttpClient defaultHeaders #19628

Closed
wants to merge 1 commit into from

Conversation

crowlKats
Copy link
Member

@crowlKats crowlKats commented Jun 27, 2023

This adds an option to specify headers in createHttpClient, without any filters.
This is useful for setting forbidden headers (ie host header).
Closes #16840
Ref #11017

@bartlomieju bartlomieju added this to the 1.35 milestone Jun 28, 2023
Copy link
Member

@bartlomieju bartlomieju left a comment

Choose a reason for hiding this comment

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

LGTM, since it's an unstable API and this seems very useful.

@andreubotella
Copy link
Contributor

Wouldn't it be better to have an allowHost option to allow specifying a Host header in the request without the filtering? I know this doesn't currently work because the Deno.HttpClient is only passed on the call to fetch, rather than on request construction, but it seems like client could be part of RequestInit just fine. Note that response headers aren't filtered in Deno.

Note that this issue might be relevant to the work we're doing in WinterCG with forking the Fetch spec to cover the needs of server-side runtimes.

@bartlomieju
Copy link
Member

Good point @andreubotella, I'm gonna defer to @lucacasonato to decide.

@lucacasonato
Copy link
Member

I agree with the allowHost option. It should be passed on the Deno.HttpClient. Request should not filter out the Host header in JS, but rather it should be filtered in Rust based on whether the client has this option set or not.

Because of this it should not matter that Request does not have a client option, because it would never affect the JS side of Request, only ever the fetch itself.

FYI on the footgun that caused us to block this in the first place: denoland/deploy_feedback#52

@crowlKats
Copy link
Member Author

crowlKats commented Jul 3, 2023

Closing in favour of #19689

@crowlKats crowlKats closed this Jul 3, 2023
@crowlKats crowlKats deleted the httpclient_defaultheaders branch July 10, 2023 07:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Fetch allow modifying Host header
4 participants