Fix multiple ws_connect with headers dict #1643
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
What do these changes do?
Currently in my client, I'm generating a headers dictionary that is used for all websockets connections. What I found is that when ws_connect is called, the websocket key is added to this dict, which is then passed back on the next call to ws_connect. Since the default headers don't overwrite the headers dict, the stale secret key is sent to the server, and the connection fails.
This change forces the secret key to overwrite the existing headers, since it is (and should) be regenerated for each connection. We might also want to consider copying the incoming dict before making changes, but that's another issue.
Are there changes in behavior for the user?
No
Related issue number
Checklist
CONTRIBUTORS.txt
CHANGES.rst
#issue_number
format at the end of changelog message. Use Pull Request number if there are no issues for PR or PR covers the issue only partially.