zmc
2023-10-12 ed135d79df12a2466b52dae1a82326941211dcc9
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
U
 ý°dnã@sÔddlmZddlZddlZddlmZddlmZmZej    ej
e e ej e e ffZejrjddlmZdd    d
œd d „Zeddfd dddddœdd„Zddddœdd„Zddœdd„Zdd    dœdd „Zed!ƒZdS)"é)Ú annotationsNé)ÚLocationParseErroré)Ú_DEFAULT_TIMEOUTÚ _TYPE_TIMEOUT)ÚBaseHTTPConnectionrÚbool)ÚconnÚreturncCs|j S)z
    Returns True if the connection is dropped and should be closed.
    :param conn: :class:`urllib3.connection.HTTPConnection` object.
    )Z is_connected)r
©r úNd:\z\workplace\vscode\pyvenv\venv\Lib\site-packages\urllib3/util/connection.pyÚis_connection_droppedsrztuple[str, int]rztuple[str, int] | Nonez_TYPE_SOCKET_OPTIONS | Nonez socket.socket)ÚaddressÚtimeoutÚsource_addressÚsocket_optionsr c Cs:|\}}| d¡r| d¡}d}tƒ}z| d¡Wn&tk
rZtd|›dƒd‚YnXt |||tj¡D]¢}|\}    }
} } } d}zPt |    |
| ¡}t    ||ƒ|t
k    r°|  |¡|r¾|  |¡|  | ¡d}|WStk
r}z|}|dk    rþ| ¡W5d}~XYqnXqn|dk    r.z|‚W5d}Xntdƒ‚dS)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)rrrrÚhostÚportÚerrÚfamilyÚresÚafÚsocktypeÚprotoÚ    canonnameÚsaÚsockÚ_r r r Úcreate_connections>
 
 
 
 
 
 
 
 
r0ÚNone)r.Úoptionsr cCs$|dkr dS|D]}|j|ŽqdS)N)Ú
setsockopt)r.r2Úoptr r r r]srzsocket.AddressFamily)r cCstj}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'r r r rgsrÚstr)r$r cCsVd}d}tjrFz"t tj¡}| |df¡d}Wntk
rDYnX|rR| ¡|S)z4Returns True if the system can bind an IPv6 address.NFrT)rÚhas_ipv6ÚAF_INET6r Ú    Exceptionr#)r$r.r9r r r Ú    _has_ipv6rs r<z::1)Ú
__future__rrÚtypingÚ
exceptionsrrrrÚSequenceÚTupleÚintÚUnionÚbytesZ_TYPE_SOCKET_OPTIONSÚ TYPE_CHECKINGZ_base_connectionrrr0rrr<r6r r r r Ú<module>s     üB