Additional headers for WS accept message.#1361
Merged
Kludex merged 6 commits intoKludex:masterfrom Jan 6, 2022
Merged
Conversation
Owner
|
It would be cool to have this supported by unicorn as well (although is not a prerequisite). |
Contributor
Author
|
@Kludex I will handle it soon. |
a080bf5 to
128e35f
Compare
Contributor
Author
|
Here is PR for |
Kludex
requested changes
Dec 22, 2021
Co-authored-by: Marcelo Trylesinski <marcelotryle@gmail.com>
Kludex
requested changes
Jan 3, 2022
Owner
Kludex
left a comment
There was a problem hiding this comment.
Besides that, everything is cool!
Thanks @matiuszka ! 😄
Kludex
reviewed
Jan 4, 2022
Kludex
approved these changes
Jan 4, 2022
Owner
|
Thanks @matiuszka ! 😄 |
Kludex
reviewed
Jan 21, 2022
| self.exit_stack.close() | ||
| raise | ||
| self.accepted_subprotocol = message.get("subprotocol", None) | ||
| self.extra_headers = message.get("headers", None) |
Owner
There was a problem hiding this comment.
This should probably be message.get("headers", []) with #1422
Contributor
There was a problem hiding this comment.
I think this part is ok. When passing None you'll need to check assert websocket.extra_headers is None but with that change:
def test_additional_headers(test_client_factory):
def app(scope):
async def asgi(receive, send):
websocket = WebSocket(scope, receive=receive, send=send)
await websocket.accept(headers=None)
await websocket.close()
return asgi
client = test_client_factory(app)
with client.websocket_connect("/") as websocket:
assert websocket.extra_headers == []Am I missing something?
Owner
There was a problem hiding this comment.
You're not. I don't have strong feelings on this. 👍
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Hello,
Here is a proposal for improvement about supporting additional headers for the WebSocket
acceptmessages.As per disscuision in gitter: