10000 Use isbytes and istext in the backported http.client module · thecodingchicken/python-future@034d20c · GitHub
[go: up one dir, main page]

Skip to content

Commit 034d20c

Browse files
committed
Use isbytes and istext in the backported http.client module
1 parent 1d6619c commit 034d20c

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

future/standard_library/http/client.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@
7070

7171
from __future__ import (absolute_import, division,
7272
print_function, unicode_literals)
73+
from future.utils import isbytes, istext
7374
from future.builtins import *
7475

7576
import email.parser
@@ -84,6 +85,7 @@
8485
from urlparse import urlsplit
8586
from array import array
8687
import warnings
88+
import numbers
8789

8890
__all__ = ["HTTPResponse", "HTTPConnection",
8991
"HTTPException", "NotConnected", "UnknownProtocol",
@@ -703,7 +705,7 @@ def getheader(self, name, default=None):
703705
if self.headers is None:
704706
raise ResponseNotReady()
705707
headers = self.headers.get_all(name) or default
706-
if isinstance(headers, str) or not hasattr(headers, '__iter__'):
708+
if istext(headers) or not hasattr(headers, '__iter__'):
707709
return headers
708710
else:
709711
return ', '.join(headers)
@@ -909,7 +911,7 @@ def _send_output(self, message_body=None):
909911
# If msg and message_body are sent in a single send() call,
910912
# it will avoid performance problems caused by the interaction
911913
# between delayed ack and the Nagle algorithm.
912-
if isinstance(message_body, bytes):
914+
if isbytes(message_body):
913915
msg += message_body
914916
message_body = None
915917
self.send(msg)
@@ -1105,7 +1107,7 @@ def _send_request(self, method, url, body, headers):
11051107
self._set_content_length(body)
11061108
for hdr, value in headers.items():
11071109
self.putheader(hdr, value)
1108-
if isinstance(body, str):
1110+
if istext(body):
11091111
# RFC 2616 Section 3.7.1 says that text default has a
11101112
# default charset of iso-8859-1.
11111113
body = body.encode('iso-8859-1')

0 commit comments

Comments
 (0)
0