
    g\                        d dl mZ d dlZd dlZddlmZ ddlmZmZ e	e
eeej        eef         f                  Zej        rddlmZ d!dZeddfd"dZd#dZd$dZd%dZ ed           ZdS )&    )annotationsN   )LocationParseError   )_DEFAULT_TIMEOUT_TYPE_TIMEOUT)BaseHTTPConnectionconnr	   returnboolc                    | j          S )z
    Returns True if the connection is dropped and should be closed.
    :param conn: :class:`urllib3.connection.HTTPConnection` object.
    )is_connected)r
   s    S/var/www/html/4nations/venv/lib/python3.11/site-packages/urllib3/util/connection.pyis_connection_droppedr      s    
        addresstuple[str, int]timeoutr   source_addresstuple[str, int] | Nonesocket_options_TYPE_SOCKET_OPTIONS | Nonesocket.socketc                   | \  }}|                     d          r|                    d          }d}t                      }	 |                    d           n"# t          $ r t          d| d          dw xY wt          j        |||t          j                  D ]}|\  }	}
}}}d}	 t          j        |	|
|          }t          ||           |t          ur|                    |           |r|                    |           |                    |           d}|c S # t          $ r"}|}||                                 Y d}~d}~ww xY w|
	 |# d}w xY wt          d          )ak  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:`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[]Nidna'z', label empty or too longz!getaddrinfo returns an empty list)
startswithstripallowed_gai_familyencodeUnicodeErrorr   socketgetaddrinfoSOCK_STREAM_set_socket_optionsr   
settimeoutbindconnectOSErrorclose)r   r   r   r   hostporterrfamilyresafsocktypeproto	canonnamesasock_s                   r   create_connectionr8      s   $ JD$s  zz$
C
  !!FQF Q Q Q !ET!E!E!EFFDPQ !$ff6HII  -0*HeY	=Xu55D  n555...((( *		.)))LLCKKK 	 	 	C

	
 	I CJJJJ9:::s1   A A6'A3D
E	'EE	E Er6   optionsNonec                ,    |d S |D ]} | j         |  d S )N)
setsockopt)r6   r9   opts      r   r&   r&   ]   s9        r   socket.AddressFamilyc                 D    t           j        } t          rt           j        } | 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.)r#   AF_INETHAS_IPV6	AF_UNSPEC)r/   s    r   r    r    g   s     
 ^F "!Mr   r,   strc                    d}d}t           j        rI	 t          j         t           j                  }|                    | df           d}n# t          $ r Y nw xY w|r|                                 |S )z4Returns True if the system can bind an IPv6 address.NFr   T)r#   has_ipv6AF_INET6r(   	Exceptionr+   )r,   r6   rE   s      r   	_has_ipv6rH   r   s    DH 	=11DIItQi   HH 	 	 	D	  

Os   7A
 

AAz::1)r
   r	   r   r   )
r   r   r   r   r   r   r   r   r   r   )r6   r   r9   r   r   r:   )r   r>   )r,   rC   r   r   )
__future__r   r#   typing
exceptionsr   r   r   r   listtupleintUnionbytes_TYPE_SOCKET_OPTIONSTYPE_CHECKING_base_connectionr	   r   r8   r&   r    rH   rA    r   r   <module>rU      s   " " " " " "   + + + + + + 4 4 4 4 4 4 4 4E#sFLe,D"DEF 	 6555555! ! ! ! .-126	?; ?; ?; ?; ?;D         . 9Ur   