HOME


Mini Shell 1.0
DIR: /lib/python3/dist-packages/urllib3/util/__pycache__/
Upload File :
Current File : //lib/python3/dist-packages/urllib3/util/__pycache__/connection.cpython-312.pyc
�

�gn���ddlmZddlZddlZddlmZddlmZmZejejeeejee
ffZejrddlmZdd�Zeddf									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.py�is_connection_droppedrs��
� � � � �c�~�|\}}|jd�r|jd�}d}t�}	|jd�t
j|||tj�D]r}|\}	}
}}}
d}	t
j|	|
|�}t||�|tur|j|�|r|j|�|j|
�d}|cS|�	|�td��#t$rtd|�d��d�wxYw#t$r}|}|�|j�Yd}~��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[]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)�address�timeout�source_address�socket_options�host�port�err�family�res�af�socktype�proto�	canonname�sa�sock�_s                r
�create_connectionr2sZ��$�J�D�$����s���z�z�$���
�C�
 �
!�F�Q����F���!�!�$��f�f�6H�6H�I���-0�*��H�e�Y����	��=�=��X�u�5�D�
 ��n�5��.�.�����(���	�	�.�)��L�L����C��K�!�.��	��I�
�9�:�:��C�Q� �1�T�F�*D�!E�F�D�P�Q��*�	��C����
�
����	���C�s0�C1�:A#D�$D8�1D�	D5�D0�0D5�8D<c�6�|�y|D]}|j|��y)N)�
setsockopt)r0�options�opts   r
rr]s)��������������rc�R�tj}trtj}|S)z�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.)r�AF_INET�HAS_IPV6�	AF_UNSPEC)r)s r
rrgs ��
�^�^�F���!�!���Mrc���d}d}tjr9	tjtj�}|j|df�d}|r|j�|S#t$rY�wxYw)z4Returns True if the system can bind an IPv6 address.NFrT)r�has_ipv6�AF_INET6r�	Exceptionr!)r&r0r<s   r
�	_has_ipv6r?rsf���D��H�
���	��=�=����1�D��I�I�t�Q�i� ��H���
�
���O���	��	�s�8A"�"	A.�-A.z::1)rr	�return�bool)
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__rr�typing�
exceptionsrr#rr�Sequence�Tuple�int�Union�bytes�_TYPE_SOCKET_OPTIONS�
TYPE_CHECKING�_base_connectionr	rr2rrr?r9�rr
�<module>rRs���"�
�
�+�4����v�|�|�C��f�l�l�3�PU�:�>V�4V�'W�X��	���5�!�.�-1�26�	?;�
�?;�
�?;�+�?;�0�	?;�
�?;�D�
��"=��	����.�U��r