kopia lustrzana https://github.com/cirospaciari/socketify.py
force application/json when using json serializer in send
rodzic
981f65c8d7
commit
99f54d900d
|
@ -1751,7 +1751,6 @@ class AppResponse:
|
||||||
return self
|
return self
|
||||||
|
|
||||||
self.write_status(status)
|
self.write_status(status)
|
||||||
self.write_header(b"Content-Type", content_type)
|
|
||||||
|
|
||||||
if headers is not None:
|
if headers is not None:
|
||||||
for name, value in headers:
|
for name, value in headers:
|
||||||
|
@ -1762,13 +1761,19 @@ class AppResponse:
|
||||||
self._write_jar = None
|
self._write_jar = None
|
||||||
if isinstance(message, str):
|
if isinstance(message, str):
|
||||||
data = message.encode("utf-8")
|
data = message.encode("utf-8")
|
||||||
|
self.write_header(b"Content-Type", content_type)
|
||||||
elif isinstance(message, bytes):
|
elif isinstance(message, bytes):
|
||||||
|
self.write_header(b"Content-Type", content_type)
|
||||||
data = message
|
data = message
|
||||||
elif message is None:
|
elif message is None:
|
||||||
|
self.write_header(b"Content-Type", content_type)
|
||||||
self.end_without_body(end_connection)
|
self.end_without_body(end_connection)
|
||||||
return self
|
return self
|
||||||
else:
|
else:
|
||||||
data = self.app._json_serializer.dumps(message).encode("utf-8")
|
data = self.app._json_serializer.dumps(message).encode("utf-8")
|
||||||
|
# ignores content_type should always be json here
|
||||||
|
self.write_header(b"Content-Type", b'application/json')
|
||||||
|
|
||||||
lib.uws_res_end(
|
lib.uws_res_end(
|
||||||
self.app.SSL, self.res, data, len(data), 1 if end_connection else 0
|
self.app.SSL, self.res, data, len(data), 1 if end_connection else 0
|
||||||
)
|
)
|
||||||
|
|
Ładowanie…
Reference in New Issue