D7net
Home
Console
Upload
information
Create File
Create Folder
About
Tools
:
/
opt
/
alt
/
python37
/
lib
/
python3.7
/
site-packages
/
urllib3
/
util
/
__pycache__
/
Filename :
connection.cpython-37.pyc
back
Copy
B �B�hn � @ 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 �H/opt/alt/python37/lib/python3.7/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 s6 | \}}|� d�r|�d�}d}t� }y|�d� W n& tk rZ td|� d��d�Y nX x�t�|||tj�D ]�}|\} } }}} d}yJt�| | |�}t ||� |t k r�|�|� |r�|�|� |� | � d}|S tk �r } z|}|dk r�|�� W dd}~X Y qpX qpW |dk �r*z|�W dd}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>