Simplify complex expression.

This commit is contained in:
Jeremy Hylton 2009-03-26 22:04:05 +00:00
parent 5f28b7b797
commit ef9f48e578
1 changed files with 3 additions and 1 deletions

View File

@ -906,7 +906,9 @@ class HTTPConnection:
self._set_content_length(body)
for hdr, value in headers.items():
self.putheader(hdr, value)
self.endheaders(body.encode('ascii') if isinstance(body, str) else body)
if isinstance(body, str):
body = body.encode('ascii')
self.endheaders(body)
def getresponse(self):
"""Get the response from the server."""