""" Returns True if the connection is dropped and should be closed.
:param conn: :class:`httplib.HTTPConnection` object.
Note: For platforms like AppEngine, this will always return ``False`` to let the platform handle connection recycling transparently for us. """ return False # Returns True if readable, which here means it's been dropped except NoWayToWaitForSocketError: # Platform-specific: AppEngine return False
# This function is copied from socket.py in the Python 2.7 standard # library test suite. Added to its signature is only `socket_options`. # One additional modification is that we avoid binding to IPv6 servers # discovered in DNS if the system doesn't have IPv6 functionality. address, timeout=socket._GLOBAL_DEFAULT_TIMEOUT, source_address=None, socket_options=None, ): """Connect to *address* and return the socket object.
Convenience function. Connect to *address* (a 2-tuple ``(host, port)``) and return the socket object. Passing the optional *timeout* parameter will set the timeout on the socket instance before attempting to connect. If no *timeout* is supplied, the global default timeout setting returned by :func:`getdefaulttimeout` is used. If *source_address* is set it must be a tuple of (host, port) for the socket to bind as a source address before making the connection. An host of '' or port 0 tells the OS to use the default. """
host = host.strip("[]")
# Using the value from allowed_gai_family() in the context of getaddrinfo lets # us select whether to work with IPv4 DNS records, IPv6 records, or both. # The original create_connection function always returns all records.
# If provided, set socket level options before connecting.
sock.bind(source_address)
except socket.error as e: err = e if sock is not None: sock.close() sock = None
if err is not None: raise err
raise socket.error("getaddrinfo returns an empty list")
return
"""This function is designed to work in the context of getaddrinfo, where family=socket.AF_UNSPEC is the default and will perform a DNS search for both IPv6 and IPv4 records."""
family = socket.AF_UNSPEC
""" Returns True if the system can bind an IPv6 address. """
# App Engine doesn't support IPV6 sockets and actually has a quota on the # number of sockets that can be used, so just early out here instead of # creating a socket needlessly. # See https://github.com/urllib3/urllib3/issues/1446 return False
# has_ipv6 returns true if cPython was compiled with IPv6 support. # It does not tell us if the system has IPv6 support enabled. To # determine that we must bind to an IPv6 address. # https://github.com/urllib3/urllib3/pull/611 # https://bugs.python.org/issue658327 has_ipv6 = True
|