File manager - Edit - /opt/gsutil/third_party/urllib3/src/urllib3/util/__pycache__/connection.cpython-39.pyc
Back
a '�ofn � @ 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. )�is_connected)r � r �>/opt/gsutil/third_party/urllib3/src/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$ tyX td|� d��d�Y n0 t�|||tj�D ]�}|\} } }}} d}zPt�| | |�}t ||� |t ur�|�|� |r�|�|� |� | � d}|W S t�y } z |}|dur�|�� W Y d}~qld}~0 0 ql|du�r0z|�W d}nd}0 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>