관리-도구
편집 파일: connection.cpython-38.pyc
U )�en � @ s� d dl mZ d dlZd dlZddlmZ ddlmZmZ ej ej eeejee f f ZejrjddlmZ dd d �dd�Zeddfd ddddd�dd�Zdddd�dd�Zdd�dd�Zdd d�dd �Zed!�ZdS )"� )�annotationsN� )�LocationParseError� )�_DEFAULT_TIMEOUT� _TYPE_TIMEOUT)�BaseHTTPConnectionr �bool)�conn�returnc C s | j S )z� Returns True if the connection is dropped and should be closed. :param conn: :class:`urllib3.connection.HTTPConnection` object. )Zis_connected)r � r �E/opt/hc_python/lib/python3.8/site-packages/urllib3/util/connection.py�is_connection_dropped s r ztuple[str, int]r ztuple[str, int] | Nonez_TYPE_SOCKET_OPTIONS | Nonez socket.socket)�address�timeout�source_address�socket_optionsr c C s: | \}}|� d�r|�d�}d}t� }z|�d� W n& tk rZ td|� d��d�Y nX t�|||tj�D ]�}|\} } }}} d}zPt�| | |�}t ||� |t k r�|�|� |r�|�|� |� | � d}|W S tk �r } z|}|dk � r�|�� W 5 d}~X Y qnX qn|dk �r.z|�W 5 d}X ntd��dS )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 s>