Handle scope path if it is a string

I ran into this while running a unit test with httpx.AsyncClient
This commit is contained in:
Simon Willison 2020-03-02 12:01:10 -08:00
commit dc80e779a2

View file

@ -48,7 +48,11 @@ class Request:
if "raw_path" in self.scope:
return self.scope["raw_path"].decode("latin-1")
else:
return self.scope["path"].decode("utf-8")
path = self.scope["path"]
if isinstance(path, str):
return path
else:
return path.decode("utf-8")
@property
def query_string(self):