diff options
author | Martin v. Löwis <martin@v.loewis.de> | 2007-06-30 09:22:09 (GMT) |
---|---|---|
committer | Martin v. Löwis <martin@v.loewis.de> | 2007-06-30 09:22:09 (GMT) |
commit | dd5a86070cdd636dd0def3fd5900b0b8405f0b6b (patch) | |
tree | c24e47916b4f904bcffa0e75c864a60a9fbc19b9 /Lib/httplib.py | |
parent | 486364b821ad25bc33e7247539d2c48a9e3b7051 (diff) | |
download | cpython-dd5a86070cdd636dd0def3fd5900b0b8405f0b6b.zip cpython-dd5a86070cdd636dd0def3fd5900b0b8405f0b6b.tar.gz cpython-dd5a86070cdd636dd0def3fd5900b0b8405f0b6b.tar.bz2 |
Fix test_httplib.
Diffstat (limited to 'Lib/httplib.py')
-rw-r--r-- | Lib/httplib.py | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/Lib/httplib.py b/Lib/httplib.py index 2a74e54..5c15f9d 100644 --- a/Lib/httplib.py +++ b/Lib/httplib.py @@ -711,8 +711,8 @@ class HTTPConnection: Appends an extra \\r\\n to the buffer. """ - self._buffer.extend(("", "")) - msg = "\r\n".join(self._buffer) + self._buffer.extend((b"", b"")) + msg = b"\r\n".join(self._buffer) del self._buffer[:] self.send(msg) @@ -758,9 +758,10 @@ class HTTPConnection: self._method = method if not url: url = '/' - str = '%s %s %s' % (method, url, self._http_vsn_str) + request = '%s %s %s' % (method, url, self._http_vsn_str) - self._output(str) + # Non-ASCII characters should have been eliminated earlier + self._output(request.encode('ascii')) if self._http_vsn == 11: # Issue some standard headers for better HTTP/1.1 compliance @@ -831,8 +832,8 @@ class HTTPConnection: if self.__state != _CS_REQ_STARTED: raise CannotSendHeader() - str = '%s: %s' % (header, value) - self._output(str) + header = '%s: %s' % (header, value) + self._output(header.encode('ascii')) def endheaders(self): """Indicate that the last header line has been sent to the server.""" @@ -846,7 +847,6 @@ class HTTPConnection: def request(self, method, url, body=None, headers={}): """Send a complete request to the server.""" - try: self._send_request(method, url, body, headers) except socket.error as v: @@ -888,6 +888,7 @@ class HTTPConnection: self.endheaders() if body: + if isinstance(body, str): body = body.encode('ascii') self.send(body) def getresponse(self): |