-
-
Notifications
You must be signed in to change notification settings - Fork 531
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
Additional headers not being used correctly #1583
Comments
I used fiddler to inspect the requests going out |
Found out the reason for the duplicate user_agent. In previous versions of websockets I passed useragent with extra_headers. Now user_agent_header is an argument in connect(). So by not passing it it was defaulting to the python/3.9... one. While in additional_headers (previously extra_headers) I had also user_agent so both were passed. This might be something to be fixed (checking if extra_headers already contains useragent string before defaulting). Now I still dont know why in the initial request the headers are not custom any info would be appreciated meanwhile I will try to dig deeper. |
The first request is performed by your intercepting proxy, Fiddler, probably to fetch the certificate from the target server. websockets isn't involved there. For the rest, sorry, it's a long story:
You raise the question of what should be done in case The legacy implementation doesn't create a duplicate: request_headers.setdefault("User-Agent", self.user_agent_header) The new asyncio and threading implementations create a duplicate: self.request.headers["User-Agent"] = user_agent_header You're suggesting that the new implementations should behave like the legacy implementation. This sounds sensible. I /think/ that my reasoning at the time was " The counter argument is: |
This will be fixed in the next version & documented in the upgrade guide. |
Hi issue I am encountering is in regards with additional_headers.
Firstly when connection is made the opening handshake requests headers don't match my custom headers
Also in the second request (101 switching protocols) while the additional_headers I set are all present, there is 2 user agent headers. One is my custom one from additional_headers the other (is the problem) it shouldn't be there "Python/3.9 websockets/14.2"
I am unsure but I think in previous versions that was not the case.
The text was updated successfully, but these errors were encountered: