File manager - Edit - /usr/local/CyberCP/lib/python3.10/site-packages/urllib3/util/__pycache__/connection.cpython-310.pyc
Back
o �h\ � @ s� d dl mZ d dlZd dlZddlmZ ddlmZmZ e e eeejee f f Zejr3ddlmZ d&dd �Zeddfd'dd�Zd(dd�Zd)dd �Zd*d#d$�Zed%�ZdS )+� )�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. )�is_connected)r � r �J/usr/local/CyberCP/lib/python3.10/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 ty* td|� d��d�w t�|||tj�D ]O}|\} } }}} d}z(t�| | |�}t ||� |t urU|�|� |r\|�|� |� | � d}|W S ty� } z|}|dury|�� W Y d}~q4d}~ww |dur�z|�d}w td��)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 � ��r5 r3 �options�Nonec C s$ |d u rd S |D ]}| j |� qd S )N)� setsockopt)r3 r6 �optr r r r# ] s �r# �socket.AddressFamilyc C s t j} trt j} | 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, r r r r g s r r) �strc C sT d}d}t jr"zt � t j�}|�| df� d}W n ty! Y nw |r(|�� |S )z4Returns True if the system can bind an IPv6 address.NFr T)r �has_ipv6�AF_INET6r% � Exceptionr( )r) r3 r? r r r � _has_ipv6r s �rB z::1)r r r r ) r r r r r r r r r r )r3 r r6 r r r7 )r r: )r) r>