Stop overriding Host and User-Agent headers #365
Conversation
Vapor's HTTPClient implementation would previously always override the Host and User-Agent headers when sending a request to the server. At best this was undesired behaviour, at worst it would result in HTTP 400 Bad Request responses. Now, default values will only be provided if Host or User-Agent headers were not already set.
Nice! Could you add some tests? |
We use https://github.com/swift-server/swift-nio-http-client now on master. I'm not sure if that package has the same problem, but it's worth checking. This repo will likely be deprecated soon. |
@tanner0101 @0xTim I've added unit tests, I had to change the visibility of some sections from private to internal. Let me know what you think. |
@OnlyForF1 ah, sorry, I didn't see that this was merging into |
I've refactored the tests to use httpbin, and reverted the visibility changes. |
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.
Great, thanks!
Hey @OnlyForF1, you just merged a pull request, have a coin! You now have 1 coins. |
Vapor's HTTPClient implementation would previously always override the
Host and User-Agent headers when sending a request to the server. At
best this was undesired behaviour, at worst it would result in
HTTP 400 Bad Request responses.
Now, default values will only be provided if Host or User-Agent headers
were not already set.