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.
........
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 @@
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 @@
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 @@
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 @@
"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