diff options
author | Gregory P. Smith <greg@mad-scientist.com> | 2010-01-03 03:28:29 (GMT) |
---|---|---|
committer | Gregory P. Smith <greg@mad-scientist.com> | 2010-01-03 03:28:29 (GMT) |
commit | b4066374db45af2927eb5cde68f9b030eaec1b96 (patch) | |
tree | 1c09a2cc471c099ab2e1cbd8d4d29d30a38b3276 /Lib/http | |
parent | 91ae4a1404fabc236a835cd5dd058f7e6b32062b (diff) | |
download | cpython-b4066374db45af2927eb5cde68f9b030eaec1b96.zip cpython-b4066374db45af2927eb5cde68f9b030eaec1b96.tar.gz cpython-b4066374db45af2927eb5cde68f9b030eaec1b96.tar.bz2 |
Merged revisions 77263-77264 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r77263 | gregory.p.smith | 2010-01-02 17:29:44 -0800 (Sat, 02 Jan 2010) | 4 lines
Adds an optional source_address parameter to socket.create_connection().
For use by issue3972.
........
r77264 | gregory.p.smith | 2010-01-02 18:06:07 -0800 (Sat, 02 Jan 2010) | 5 lines
issue3972: HTTPConnection and HTTPSConnection now support a
source_address parameter.
Also cleans up an annotation in the socket documentation.
........
Diffstat (limited to 'Lib/http')
-rw-r--r-- | Lib/http/client.py | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/Lib/http/client.py b/Lib/http/client.py index 5581903..d35f245 100644 --- a/Lib/http/client.py +++ b/Lib/http/client.py @@ -634,8 +634,9 @@ class HTTPConnection: strict = 0 def __init__(self, host, port=None, strict=None, - timeout=socket._GLOBAL_DEFAULT_TIMEOUT): + timeout=socket._GLOBAL_DEFAULT_TIMEOUT, source_address=None): self.timeout = timeout + self.source_address = source_address self.sock = None self._buffer = [] self.__response = None @@ -707,7 +708,7 @@ class HTTPConnection: def connect(self): """Connect to the host and port specified in __init__.""" self.sock = socket.create_connection((self.host,self.port), - self.timeout) + self.timeout, self.source_address) if self._tunnel_host: self._tunnel() @@ -1042,8 +1043,10 @@ else: default_port = HTTPS_PORT def __init__(self, host, port=None, key_file=None, cert_file=None, - strict=None, timeout=socket._GLOBAL_DEFAULT_TIMEOUT): - HTTPConnection.__init__(self, host, port, strict, timeout) + strict=None, timeout=socket._GLOBAL_DEFAULT_TIMEOUT, + source_address=None): + super(HTTPSConnection, self).__init__(host, port, strict, timeout, + source_address) self.key_file = key_file self.cert_file = cert_file @@ -1051,7 +1054,7 @@ else: "Connect to a host on a given (SSL) port." sock = socket.create_connection((self.host, self.port), - self.timeout) + self.timeout, self.source_address) if self._tunnel_host: self.sock = sock |