Skip to content

Commit

Permalink
Return raw_path as byte string
Browse files Browse the repository at this point in the history
According to ASGI spec [0], connection scope's `raw_path` should be a
byte string.

[0] https://asgi.readthedocs.io/en/latest/specs/www.html#connection-scope
  • Loading branch information
trimailov committed Jan 30, 2020
1 parent 93c4249 commit 39f448d
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions starlette/testclient.py
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ def send(
scope = {
"type": "websocket",
"path": unquote(path),
"raw_path": path,
"raw_path": path.encode(),
"root_path": self.root_path,
"scheme": scheme,
"query_string": query.encode(),
Expand All @@ -151,7 +151,7 @@ def send(
"http_version": "1.1",
"method": request.method,
"path": unquote(path),
"raw_path": path,
"raw_path": path.encode(),
"root_path": self.root_path,
"scheme": scheme,
"query_string": query.encode(),
Expand Down
2 changes: 1 addition & 1 deletion tests/test_requests.py
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ async def app(scope, receive, send):

client = TestClient(app)
response = client.get("/he%2Fllo")
assert response.text == "/he/llo, /he%2Fllo"
assert response.text == "/he/llo, b'/he%2Fllo'"


def test_request_without_setting_receive():
Expand Down

0 comments on commit 39f448d

Please sign in to comment.