Skip to content

Set host header on new request (async/await only) #536

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

Merged
merged 2 commits into from
Dec 24, 2021

Conversation

dnadoba
Copy link
Collaborator

@dnadoba dnadoba commented Dec 22, 2021

Motivation

If we follow a redirect which changes the origin e.g. from 127.0.0.1 to localhost we didn't change the Host header to the appropriate new origin and port combination.

Changes

Use the original request which does not include the host instead of the prepared request to form a new request to the redirect URL.

Alternatives

If the user defines a Host header themselves on the original HTTPClientRequest we currently never touch it, even in the redirect case. Maybe we should change our strategy and do one of the following:

  1. We could always override the user defined Host header
  2. We could only remove the user defined Host header on redirect and set it to the new origin and port combination

Copy link
Collaborator

@FranzBusch FranzBusch left a comment

Choose a reason for hiding this comment

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

LGTM

### Motivation
If we follow a redirect which changes the origin e.g. from `127.0.0.1` to `localhost` we didn't change the `Host` header to the appropriate new origin and port combination.
### Changes
Use the original request which does not include the host instead of the prepared request to form a new request to the redirect URL.

### Alternatives
If the user defines a `Host` header themselves on the original `HTTPClientRequest` we currently never touch it, even in the redirect case. Maybe we should change our strategy and do one of the following:
1. We could always override the user defined `Host` header
2. We could only remove the user defined `Host` header on redirect and set it to the new origin and port combination
@dnadoba dnadoba force-pushed the dn-async-await-redirect-fix branch from 2d3c0e1 to 7e14224 Compare December 22, 2021 23:09
@dnadoba dnadoba added the 🔨 semver/patch No public API change. label Dec 23, 2021
@dnadoba dnadoba merged commit 19e83a3 into swift-server:main Dec 24, 2021
@dnadoba dnadoba deleted the dn-async-await-redirect-fix branch December 24, 2021 11:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🔨 semver/patch No public API change.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants