Handle scope path if it is a string

I ran into this while running a unit test with httpx.AsyncClient
pull/652/head^2
Simon Willison 2020-03-02 12:01:10 -08:00
rodzic 4933035b75
commit dc80e779a2
1 zmienionych plików z 5 dodań i 1 usunięć

Wyświetl plik

@ -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):