fix: add websocket prefix to StreamingResponse and FileResponse denia…#3051
Open
martin-joshy wants to merge 6 commits intoKludex:mainfrom
Open
fix: add websocket prefix to StreamingResponse and FileResponse denia…#3051martin-joshy wants to merge 6 commits intoKludex:mainfrom
martin-joshy wants to merge 6 commits intoKludex:mainfrom
Conversation
Owner
|
I think what we want is a async def _send_wrap(send: Send, is_websocket_denial: bool):
async def wrapped(message: Message):
if is_websocket_denial:
message["type"] = "websocket." + message["type"]
await send(message)
return wrappedThe idea is to avoid the additional parameter everywhere. |
…se denial (Kludex#3048)" This reverts commit f70425a.
Author
|
Hi, thanks for the snippet it made it lot clearer. Below is the code which I tried to run test with, but I am not get 100 % coverage. Not really sure what I should be doing. async def send_denial_response(self, response: Response) -> None:
if "websocket.http.response" in self.scope.get("extensions", {}):
wrapped_send = self._send_wrap(self.send)
await response(self.scope, self.receive, wrapped_send)
else:
raise RuntimeError("The server doesn't support the Websocket Denial Response extension.")
@staticmethod
def _send_wrap(send: Send) -> Send:
async def wrapped(message: Message) -> None:
message_type = message["type"]
if message_type.startswith("http."):
message["type"] = "websocket." + message_type
await send(message)
return wrapped |
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.
…l (#3048)
Hi, this is my first time contribution to open source ever, welcome to all kind feedbacks
Summary
StreamingResponseandFileResponsesent rawhttp.response.*messages duringsend_denial_response, but WebSocket context requireswebsocket.http.response.*prefix.This caused: