Skip to content

Commit

Permalink
Turn raw_path into bytes on both websockets implementations (encode…
Browse files Browse the repository at this point in the history
…#1487)

* Turn `raw_path` into bytes

* fix tests
  • Loading branch information
Kludex committed Oct 29, 2022
1 parent 688e943 commit 626b9da
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion tests/protocols/test_websocket.py
Expand Up @@ -220,7 +220,7 @@ async def websocket_connect(self, message):
path = self.scope.get("path")
raw_path = self.scope.get("raw_path")
assert path == "/one/two"
assert raw_path == "/one%2Ftwo"
assert raw_path == b"/one%2Ftwo"
await self.send({"type": "websocket.accept"})

async def open_connection(url):
Expand Down
2 changes: 1 addition & 1 deletion uvicorn/protocols/websockets/websockets_impl.py
Expand Up @@ -133,7 +133,7 @@ async def process_request(self, path, headers):
"client": self.client,
"root_path": self.root_path,
"path": unquote(path_portion),
"raw_path": path_portion,
"raw_path": path_portion.encode("ascii"),
"query_string": query_string.encode("ascii"),
"headers": asgi_headers,
"subprotocols": subprotocols,
Expand Down
2 changes: 1 addition & 1 deletion uvicorn/protocols/websockets/wsproto_impl.py
Expand Up @@ -143,7 +143,7 @@ def handle_connect(self, event):
"client": self.client,
"root_path": self.root_path,
"path": unquote(raw_path),
"raw_path": raw_path,
"raw_path": raw_path.encode("ascii"),
"query_string": query_string.encode("ascii"),
"headers": headers,
"subprotocols": event.subprotocols,
Expand Down

0 comments on commit 626b9da

Please sign in to comment.