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:
|
||||
timeout_header = b'Keep-Alive: %d\r\n' % keep_alive_timeout
|
||||
|
||||
body = b''
|
||||
content_length = 0
|
||||
if self.status is not 204:
|
||||
body = 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(
|
||||
'Content-Type', self.content_type)
|
||||
|
||||
|
@ -222,7 +224,7 @@ class HTTPResponse(BaseHTTPResponse):
|
|||
b'keep-alive' if keep_alive else b'close',
|
||||
timeout_header,
|
||||
headers,
|
||||
self.body if self.status is not 204 else b''
|
||||
body
|
||||
)
|
||||
|
||||
@property
|
||||
|
|
Loading…
Reference in New Issue
Block a user