|
1 | 1 | """HTTP/1.1 client library |
2 | 2 |
|
3 | | -From Python 3.3 |
| 3 | +A backport of the Python 3.3 module to Python 2.7 using ``future``. |
4 | 4 |
|
5 | | -<intro stuff goes here> |
6 | | -<other stuff, too> |
| 5 | +-------------- |
7 | 6 |
|
8 | 7 | HTTPConnection goes through a number of "states", which define when a client |
9 | 8 | may legally make another request or fetch the response for a particular |
|
70 | 69 |
|
71 | 70 | from __future__ import (absolute_import, division, |
72 | 71 | print_function, unicode_literals) |
73 | | -from future.utils import isbytes, istext |
74 | 72 | from future.builtins import * |
| 73 | +from future.utils import isbytes, istext |
75 | 74 |
|
76 | 75 | import email.parser |
77 | 76 | import email.message |
|
83 | 82 | # from urllib.parse import urlsplit |
84 | 83 | # Use the Py2.7 equivalent: |
85 | 84 | from urlparse import urlsplit |
86 | | -from array import array |
| 85 | + |
87 | 86 | import warnings |
88 | 87 | import numbers |
| 88 | +from array import array |
89 | 89 |
|
90 | 90 | __all__ = ["HTTPResponse", "HTTPConnection", |
91 | 91 | "HTTPException", "NotConnected", "UnknownProtocol", |
@@ -1202,59 +1202,6 @@ def connect(self): |
1202 | 1202 | __all__.append("HTTPSConnection") |
1203 | 1203 |
|
1204 | 1204 |
|
1205 | | - ###################################### |
1206 | | - # class HTTPSConnection(HTTPConnection): |
1207 | | - # "This class allows communication via SSL." |
1208 | | - |
1209 | | - # default_port = HTTPS_PORT |
1210 | | - |
1211 | | - # # XXX Should key_file and cert_file be deprecated in favour of context? |
1212 | | - |
1213 | | - # def __init__(self, host, port=None, key_file=None, cert_file=None, |
1214 | | - # strict=_strict_sentinel, timeout=socket._GLOBAL_DEFAULT_TIMEOUT, |
1215 | | - # source_address=None, context=None, check_hostname=None): |
1216 | | - # super(HTTPSConnection, self).__init__(host, port, strict, timeout, |
1217 | | - # source_address) |
1218 | | - # self.key_file = key_file |
1219 | | - # self.cert_file = cert_file |
1220 | | - # if context is None: |
1221 | | - # # Some reasonable defaults |
1222 | | - # context = ssl.SSLContext(ssl.PROTOCOL_SSLv23) |
1223 | | - # context.options |= ssl.OP_NO_SSLv2 |
1224 | | - # will_verify = context.verify_mode != ssl.CERT_NONE |
1225 | | - # if check_hostname is None: |
1226 | | - # check_hostname = will_verify |
1227 | | - # elif check_hostname and not will_verify: |
1228 | | - # raise ValueError("check_hostname needs a SSL context with " |
1229 | | - # "either CERT_OPTIONAL or CERT_REQUIRED") |
1230 | | - # if key_file or cert_file: |
1231 | | - # context.load_cert_chain(cert_file, key_file) |
1232 | | - # self._context = context |
1233 | | - # self._check_hostname = check_hostname |
1234 | | - |
1235 | | - # def connect(self): |
1236 | | - # "Connect to a host on a given (SSL) port." |
1237 | | - |
1238 | | - # sock = socket.create_connection((self.host, self.port), |
1239 | | - # self.timeout, self.source_address) |
1240 | | - |
1241 | | - # if self._tunnel_host: |
1242 | | - # self.sock = sock |
1243 | | - # self._tunnel() |
1244 | | - |
1245 | | - # server_hostname = self.host if ssl.HAS_SNI else None |
1246 | | - # self.sock = self._context.wrap_socket(sock, |
1247 | | - # server_hostname=server_hostname) |
1248 | | - # try: |
1249 | | - # if self._check_hostname: |
1250 | | - # ssl.match_hostname(self.sock.getpeercert(), self.host) |
1251 | | - # except Exception: |
1252 | | - # self.sock.shutdown(socket.SHUT_RDWR) |
1253 | | - # self.sock.close() |
1254 | | - # raise |
1255 | | - |
1256 | | - # __all__.append("HTTPSConnection") |
1257 | | - |
1258 | 1205 | class HTTPException(Exception): |
1259 | 1206 | # Subclasses that define an __init__ must call Exception.__init__ |
1260 | 1207 | # or define self.args. Otherwise, str() will fail. |
|
0 commit comments