-
Notifications
You must be signed in to change notification settings - Fork 117
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 Host
header (#650)
#652
base: main
Are you sure you want to change the base?
Conversation
Can one of the admins verify this patch? |
5 similar comments
Can one of the admins verify this patch? |
Can one of the admins verify this patch? |
Can one of the admins verify this patch? |
Can one of the admins verify this patch? |
Can one of the admins verify this patch? |
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! This is almost good to go.
@@ -155,7 +160,13 @@ final class HTTP1ProxyConnectHandler: ChannelDuplexHandler, RemovableChannelHand | |||
method: .CONNECT, | |||
uri: "\(self.targetHost):\(self.targetPort)" | |||
) | |||
head.headers.replaceOrAdd(name: "host", value: "\(self.targetHost)") | |||
if !head.headers.contains(name: "host") { |
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 HTTPRequestHead
is created in the lines above and we can therefore say for sure we will never have a host
set. This makes sense because we don't need to look into the headers we have created here but from the original HTTP request from the user. This will require plumping the HTTPHeader
s from the original request through the stack.
FYI: @rnro is currently working on moving HTTP1ProxyConnectHandler
to swift-nio-extras
in this PR. In this new version the HTTPHeader
s are passed into the HTTP1ProxyConnectHandler.init
which makes this a bit easier. We still need to get the original request headers to where we create the HTTP1ProxyConnectHandler
in AHC.
Added check to add host only if needed, and also building host the right way.