-
Notifications
You must be signed in to change notification settings - Fork 252
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
Conversation
There was a problem hiding this 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 }; |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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()) |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for spotting this!
4ed0520
to
f647fd3
Compare
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
f647fd3
to
18b5cf6
Compare
Ok, pushed another update. Fixing stuff. 🤦 |
Looks good now, thanks a lot! |
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