mirror of
https://github.com/correl/tornado-openapi3.git
synced 2024-12-27 11:09:53 +00:00
Leave request and response bodies as binary data
Decoding to UTF-8 text is the responsibility of the content-type loader used in the validator, and should not be done prior.
This commit is contained in:
parent
b69f690d50
commit
4102a14883
4 changed files with 5 additions and 5 deletions
|
@ -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)
|
||||
|
|
|
@ -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",
|
||||
)
|
||||
|
|
|
@ -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"
|
||||
),
|
||||
|
|
|
@ -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,
|
||||
)
|
||||
|
|
Loading…
Reference in a new issue