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

fix: replace host header by default #880

Merged
merged 1 commit into from
Oct 4, 2024

Conversation

ctron
Copy link
Collaborator

@ctron ctron commented Oct 2, 2024

This also aligns the behavior with the WS proxy behavior and adds header support for WS proxy requests too.

It also adds the XFP header.

Closes: #879

Copy link

@fiadliel fiadliel left a comment

Choose a reason for hiding this comment

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

Two issues here; the critical one is the dropping of the request method.

src/proxy.rs Outdated
// forward all inbound headers

for (key, value) in original_headers {
let Some(key) = key else { continue };
Copy link

Choose a reason for hiding this comment

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

This drops any header values for a particular header name, after the first one. I noticed this when looking at the API of the iterator for HeaderMap. Yes it's existing behavior, but it has some issues that will definitely bite someone in the future. It can drop some cookies from the request, for example.

An alternative could be to clone the original_headers, and remove HOST from the cloned map.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Good idea, I'll do that.


let mut outbound_req = state
.client
.request(req.method().clone(), outbound_uri.to_string())
Copy link

Choose a reason for hiding this comment

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

The request method got lost in the refactor.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Thanks for spotting this!

@ctron ctron force-pushed the feature/rework_host_header_1 branch from 4ed0520 to f647fd3 Compare October 2, 2024 11:34
@ctron
Copy link
Collaborator Author

ctron commented Oct 2, 2024

I just pushed an update, maybe you can give it another try.

This also aligns the behavior with the WS proxy behavior and adds header
support for WS proxy requests too.

It also adds the XFP header.

Closes: trunk-rs#879
@ctron ctron force-pushed the feature/rework_host_header_1 branch from f647fd3 to 18b5cf6 Compare October 2, 2024 11:49
@ctron
Copy link
Collaborator Author

ctron commented Oct 2, 2024

Ok, pushed another update. Fixing stuff. 🤦

@fiadliel
Copy link

fiadliel commented Oct 2, 2024

Looks good now, thanks a lot!

@ctron ctron merged commit c793b91 into trunk-rs:main Oct 4, 2024
60 checks passed
@ctron ctron deleted the feature/rework_host_header_1 branch October 4, 2024 06:46
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.

Host header from request is included in proxied requests
2 participants