o
    ;)h\                     @  s   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r3ddlmZ d&ddZeddfd'ddZd(ddZd)dd Zd*d#d$Zed%ZdS )+    )annotationsN   )LocationParseError   )_DEFAULT_TIMEOUT_TYPE_TIMEOUT)BaseHTTPConnectionconnr   returnboolc                 C  s   | j  S )z
    Returns True if the connection is dropped and should be closed.
    :param conn: :class:`urllib3.connection.HTTPConnection` object.
    )Zis_connected)r	    r   VC:\Users\User\Downloads\Proyecto_IoT\venv\Lib\site-packages\urllib3/util/connection.pyis_connection_dropped   s   r   addresstuple[str, int]timeoutr   source_addresstuple[str, int] | Nonesocket_options_TYPE_SOCKET_OPTIONS | Nonesocket.socketc                 C  s$  | \}}| dr|d}d}t }z|d W n ty*   td| ddw t|||tjD ]O}|\}	}
}}}d}z(t|	|
|}t	|| |t
urU|| |r\|| || d}|W   S  ty } z|}|dury|  W Y d}~q4d}~ww |durz|d}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_r   r   r   create_connection   sD   






r4   r2   optionsNonec                 C  s$   |d u rd S |D ]}| j |  qd S )N)
setsockopt)r2   r5   optr   r   r   r"   ]   s
   r"   socket.AddressFamilyc                  C  s   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+   r   r   r   r   g   s   r   r(   strc                 C  sT   d}d}t jr"zt  t j}|| df d}W n	 ty!   Y nw |r(|  |S )z4Returns True if the system can bind an IPv6 address.NFr   T)r   has_ipv6AF_INET6r$   	Exceptionr'   )r(   r2   r>   r   r   r   	_has_ipv6r   s   rA   z::1)r	   r   r
   r   )
r   r   r   r   r   r   r   r   r
   r   )r2   r   r5   r   r
   r6   )r
   r9   )r(   r=   r
   r   )
__future__r   r   typing
exceptionsr   r   r   r   listtupleintUnionbytesZ_TYPE_SOCKET_OPTIONSTYPE_CHECKINGZ_base_connectionr   r   r4   r"   r   rA   r;   r   r   r   r   <module>   s"    

B


