diff --git a/tests/test_requests.py b/tests/test_requests.py index 0948b09..0b19940 100644 --- a/tests/test_requests.py +++ b/tests/test_requests.py @@ -99,7 +99,7 @@ class TestRequestFactory(unittest.TestCase): full_url_pattern=url, method="get", parameters=RequestParameters(query=ImmutableMultiDict(parameters)), - body="", + body=b"", mimetype="application/x-www-form-urlencoded", ) openapi_request = TornadoRequestFactory.create(tornado_request) @@ -125,7 +125,7 @@ class TestRequestFactory(unittest.TestCase): full_url_pattern=url, method="get", parameters=RequestParameters(query=ImmutableMultiDict(parameters)), - body="", + body=b"", mimetype="application/x-www-form-urlencoded", ) openapi_request = TornadoRequestFactory.create(tornado_request) diff --git a/tests/test_responses.py b/tests/test_responses.py index e953780..6d4ebd5 100644 --- a/tests/test_responses.py +++ b/tests/test_responses.py @@ -66,7 +66,7 @@ class TestResponseFactory(unittest.TestCase): tornado_request = HTTPRequest(url="http://example.com") tornado_response = HTTPResponse(request=tornado_request, code=200) expected = OpenAPIResponse( - data="", + data=b"", status_code=200, mimetype="text/html", ) diff --git a/tornado_openapi3/requests.py b/tornado_openapi3/requests.py index 893bb7d..259f40c 100644 --- a/tornado_openapi3/requests.py +++ b/tornado_openapi3/requests.py @@ -43,7 +43,7 @@ class TornadoRequestFactory: parameters=RequestParameters( query=query_arguments, header=Headers(request.headers.get_all()) ), - body=request.body.decode("utf-8") if request.body else "", + body=request.body if request.body else b"", mimetype=request.headers.get( "Content-Type", "application/x-www-form-urlencoded" ), diff --git a/tornado_openapi3/responses.py b/tornado_openapi3/responses.py index 534f246..fc87f4a 100644 --- a/tornado_openapi3/responses.py +++ b/tornado_openapi3/responses.py @@ -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") if response.body else "", + data=response.body if response.body else b"", status_code=response.code, mimetype=mimetype, )