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 Host header (#650) #652

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

MihaelIsaev
Copy link
Contributor

Added check to add host only if needed, and also building host the right way.

@swift-server-bot
Copy link

Can one of the admins verify this patch?

5 similar comments
@swift-server-bot
Copy link

Can one of the admins verify this patch?

@swift-server-bot
Copy link

Can one of the admins verify this patch?

@swift-server-bot
Copy link

Can one of the admins verify this patch?

@swift-server-bot
Copy link

Can one of the admins verify this patch?

@swift-server-bot
Copy link

Can one of the admins verify this patch?

Copy link
Collaborator

@dnadoba dnadoba left a 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") {
Copy link
Collaborator

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 HTTPHeaders 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 HTTPHeaders 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.

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.

3 participants