simplified logic when handling the body
This commit is contained in:
parent
4b6e89a526
commit
0ab64e9803
|
@ -196,11 +196,13 @@ class HTTPResponse(BaseHTTPResponse):
|
||||||
if keep_alive and keep_alive_timeout is not None:
|
if keep_alive and keep_alive_timeout is not None:
|
||||||
timeout_header = b'Keep-Alive: %d\r\n' % keep_alive_timeout
|
timeout_header = b'Keep-Alive: %d\r\n' % keep_alive_timeout
|
||||||
|
|
||||||
|
body = b''
|
||||||
content_length = 0
|
content_length = 0
|
||||||
if self.status is not 204:
|
if self.status is not 204:
|
||||||
|
body = self.body
|
||||||
content_length = self.headers.get('Content-Length', len(self.body))
|
content_length = self.headers.get('Content-Length', len(self.body))
|
||||||
self.headers['Content-Length'] = content_length
|
|
||||||
|
|
||||||
|
self.headers['Content-Length'] = content_length
|
||||||
self.headers['Content-Type'] = self.headers.get(
|
self.headers['Content-Type'] = self.headers.get(
|
||||||
'Content-Type', self.content_type)
|
'Content-Type', self.content_type)
|
||||||
|
|
||||||
|
@ -222,7 +224,7 @@ class HTTPResponse(BaseHTTPResponse):
|
||||||
b'keep-alive' if keep_alive else b'close',
|
b'keep-alive' if keep_alive else b'close',
|
||||||
timeout_header,
|
timeout_header,
|
||||||
headers,
|
headers,
|
||||||
self.body if self.status is not 204 else b''
|
body
|
||||||
)
|
)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
|
|
Loading…
Reference in New Issue
Block a user