CYhnddlmZddlZddlZddlmZddlmZmZejeje e eje e ffZejrddlmZddZeddf dd Z dd Zdd Zdd Zed Zy)) annotationsN)LocationParseError)_DEFAULT_TIMEOUT _TYPE_TIMEOUT)BaseHTTPConnectionc|j S)z Returns True if the connection is dropped and should be closed. :param conn: :class:`urllib3.connection.HTTPConnection` object. ) is_connected)conns 9/usr/lib/python3/dist-packages/urllib3/util/connection.pyis_connection_droppedrs    c~|\}}|jdr|jd}d}t} |jdt j|||t jD]r}|\} } } } } d} t j | | | }t|||tur|j||r|j||j| d}|cS| |td#t$rt d|ddwxYw#t$r}|}||jYd}~d}~wwxYw#d}wxYw)akConnect 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:`socket.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. [z[]Nidna'z', label empty or too longz!getaddrinfo returns an empty list) startswithstripallowed_gai_familyencode UnicodeErrorrsocket getaddrinfo SOCK_STREAM_set_socket_optionsr settimeoutbindconnectOSErrorclose)addresstimeoutsource_addresssocket_optionshostporterrfamilyresafsocktypeproto canonnamesasock_s r create_connectionr2sZ$JD$ szz$ C  !FQ F!!$ff6H6HI-0*HeY ==Xu5D n 5..( .) LL CK!.  I 9::C Q 1TF*D!EFDPQ* C  Cs0C1:A#D$D81D  D5D00D58D<c6|y|D]}|j|y)N) setsockopt)r0optionsopts r rr]s)rcRtj}trtj}|S)zThis 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.)rAF_INETHAS_IPV6 AF_UNSPEC)r)s r rrgs ^^F!! Mrcd}d}tjr9 tjtj}|j|dfd}|r|j |S#t$rYwxYw)z4Returns True if the system can bind an IPv6 address.NFrT)rhas_ipv6AF_INET6r Exceptionr!)r&r0r<s r _has_ipv6r?rsf DH   ==1D IItQi H  O    s8A"" A.-A.z::1)r r returnbool) r"ztuple[str, int]r#rr$ztuple[str, int] | Noner%_TYPE_SOCKET_OPTIONS | Noner@ socket.socket)r0rCr5rBr@None)r@zsocket.AddressFamily)r&strr@rA) __future__rrtyping exceptionsrr#rrSequenceTupleintUnionbytes_TYPE_SOCKET_OPTIONS TYPE_CHECKING_base_connectionr rr2rrr?r9rr rRs" +4v||Cfll3PU:>V4V'WX 5!.-126 ?; ?; ?;+?;0 ?;  ?;D "= . U r