Handle unset response bodies

This commit is contained in:
Correl Roush 2020-11-26 00:18:36 -05:00
parent 2b2b423b7b
commit 98d112369f

View file

@ -13,7 +13,7 @@ class TornadoResponseFactory:
def create(cls, response: HTTPResponse) -> OpenAPIResponse:
mimetype = response.headers.get("Content-Type", "text/html")
return OpenAPIResponse(
data=response.body.decode("utf-8"),
data=response.body.decode("utf-8") if response.body else "",
status_code=response.code,
mimetype=mimetype,
)