zmc
2023-08-08 e792e9a60d958b93aef96050644f369feb25d61b
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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
U
I=®d}8ã    @s²ddlmZddlZddlZddlZddlZddlZddlmZm    Z
ddl Z ddl m Z ddlmZddlmZzddlZejZWn,eefk
r®dZGdd    „d    eƒZYnXzeZWn$ek
rÜGd
d „d eƒZYnXdd lmZmZmZmZdd l m!Z!m"Z"ddl#m$Z$m%Z%m&Z&m'Z'm(Z(ddl)m*Z*ddl+m,Z,e -e.¡Z/dddœZ0e 1ddd¡Z2e 3d¡Z4Gdd„de5ƒZ6Gdd„dee5ƒZGdd„deƒZ7dd„Z8esªe6Z7e7Z9dS)é)Úabsolute_importN)ÚerrorÚtimeouté)Úsix)ÚHTTPConnection)Ú HTTPExceptionc@s eZdZdS)Ú BaseSSLErrorN©Ú__name__Ú
__module__Ú __qualname__©rrúUD:\z\workplace\VsCode\pyvenv\venv\Lib\site-packages\pip/_vendor/urllib3/connection.pyr    sr    c@s eZdZdS)ÚConnectionErrorNr
rrrrrsr)ÚNewConnectionErrorÚConnectTimeoutErrorÚSubjectAltNameWarningÚSystemTimeWarning)Úmatch_hostnameÚCertificateError)Úresolve_cert_reqsÚresolve_ssl_versionÚassert_fingerprintÚcreate_urllib3_contextÚssl_wrap_socket)Ú
connection)ÚHTTPHeaderDictéPi»)ÚhttpÚhttpsiãz[^-!#$%&'*+.^_`|~0-9a-zA-Z]c@seZdZdZdS)ÚDummyConnectionz-Used to detect a failed ConnectionCls import.N)r r r Ú__doc__rrrrr!Asr!c@sxeZdZdZedZejejdfgZ    dZ
dd„Z e dd„ƒZ e jd    d„ƒZ d
d „Zd d „Zdd„Zdd„Zddd„ZdS)ra$
    Based on httplib.HTTPConnection but provides an extra constructor
    backwards-compatibility layer between older and newer Pythons.
 
    Additional keyword parameters are used to configure attributes of the connection.
    Accepted parameters include:
 
      - ``strict``: See the documentation on :class:`urllib3.connectionpool.HTTPConnectionPool`
      - ``source_address``: Set the source address for the current connection.
      - ``socket_options``: Set specific options on the underlying socket. If not specified, then
        defaults are loaded from ``HTTPConnection.default_socket_options`` which includes disabling
        Nagle's algorithm (sets TCP_NODELAY to 1) unless the connection is behind a proxy.
 
        For example, if you wish to enable TCP Keep Alive in addition to the defaults,
        you might pass::
 
            HTTPConnection.default_socket_options + [
                (socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1),
            ]
 
        Or you may want to disable the defaults by passing an empty list (e.g., ``[]``).
    rrFcOsDtjs| dd¡| d¡|_| d|j¡|_tj|f|ž|ŽdS)NÚstrictÚsource_addressÚsocket_options)    rÚPY2ÚpopÚgetr$Údefault_socket_optionsr%Ú_HTTPConnectionÚ__init__)ÚselfÚargsÚkwrrrr+hs
  zHTTPConnection.__init__cCs |j d¡S)aŸ
        Getter method to remove any trailing dots that indicate the hostname is an FQDN.
 
        In general, SSL certificates don't include the trailing dot indicating a
        fully-qualified domain name, and thus, they don't validate properly when
        checked against a domain name that includes the dot. In addition, some
        servers may not expect to receive the trailing dot when provided.
 
        However, the hostname with trailing dot is critical to DNS resolution; doing a
        lookup with the trailing dot will properly only resolve the appropriate FQDN,
        whereas a lookup without a trailing dot will search the system's search domain
        list. Thus, it's important to keep the original host around for use only in
        those cases where it's appropriate (i.e., when doing DNS lookup to establish the
        actual TCP connection across which we're going to send HTTP requests).
        Ú.)Ú    _dns_hostÚrstrip)r,rrrÚhostuszHTTPConnection.hostcCs
||_dS)z×
        Setter for the `host` property.
 
        We assume that only urllib3 uses the _dns_host attribute; httplib itself
        only uses `host`, and it seems reasonable that other libraries follow suit.
        N)r0)r,Úvaluerrrr2ˆsc
Cs i}|jr|j|d<|jr$|j|d<ztj|j|jf|jf|Ž}WnXtk
rlt|d|j    |jfƒ‚Yn0t
k
rš}zt |d|ƒ‚W5d}~XYnX|S)zp Establish a socket connection and set nodelay settings on it.
 
        :return: New socket connection.
        r$r%z0Connection to %s timed out. (connect timeout=%s)z(Failed to establish a new connection: %sN) r$r%rÚcreate_connectionr0ÚportrÚ SocketTimeoutrr2Ú SocketErrorr)r,Úextra_kwÚconnÚerrrÚ    _new_conn’s2
 
 
ÿÿ
ÿþÿzHTTPConnection._new_conncCs$||_t|ddƒr | ¡d|_dS)NÚ _tunnel_hostr)ÚsockÚgetattrÚ_tunnelÚ    auto_open©r,r9rrrÚ _prepare_conn±s zHTTPConnection._prepare_conncCs| ¡}| |¡dS)N)r;rBrArrrÚconnectºszHTTPConnection.connectcOs8t |¡}|r"td|| ¡fƒ‚tj|||f|ž|ŽS)zSend a request to the serverzAMethod cannot contain non-token characters %r (found at least %r))Ú_CONTAINS_CONTROL_CHAR_REÚsearchÚ
ValueErrorÚgroupr*Ú
putrequest)r,ÚmethodÚurlr-ÚkwargsÚmatchrrrrH¾s
 
ÿÿzHTTPConnection.putrequestNc Cst|dk    r|niƒ}d|k}d|k}|j||||d| ¡D]\}}| ||¡q>d|krh| dd¡| ¡|dk    rútjtf}    t||    ƒr”|f}|D]`}
|
s¢q˜t|
tƒs¶|
     d¡}
t
t |
ƒƒd    d…} |  |      d
¡¡|  d ¡|  |
¡|  d ¡q˜|  d ¡dS) zƒ
        Alternative to the common request method, which sends the
        body with chunked encoding and not as one block
        Nzaccept-encodingr2)Úskip_accept_encodingÚ    skip_hostztransfer-encodingzTransfer-EncodingÚchunkedÚutf8ézutf-8s
s0
 
) rrHÚitemsÚ    putheaderÚ
endheadersrÚ string_typesÚbytesÚ
isinstanceÚencodeÚhexÚlenÚsend) r,rIrJÚbodyÚheadersrMrNÚheaderr3Ústringish_typesÚchunkÚlen_strrrrÚrequest_chunkedÉs:ÿ  
 
 
 
 
 zHTTPConnection.request_chunked)NN)r r r r"Úport_by_schemeÚ default_portÚsocketÚ IPPROTO_TCPÚ TCP_NODELAYr)Ú is_verifiedr+Úpropertyr2Úsetterr;rBrCrHrbrrrrrGs 
 
         rc    @sZeZdZedZdZdZdZdZdZ    dZ
ddddde j ddfdd„Z d    dd„Zdd„ZdS)
ÚHTTPSConnectionr Nc
KsDtj|||f||dœ|
—Ž||_||_||_||_|    |_d|_dS)N)r#rr )rr+Úkey_fileÚ    cert_fileÚ key_passwordÚ ssl_contextÚserver_hostnameÚ    _protocol) r,r2r5rlrmrnr#rrorpr.rrrr+÷szHTTPSConnection.__init__c
 
Csv|dkr$|jdk    r|jj}ntdƒ}||_||_||_||_||_||_|oVt    j
  |¡|_ |oht    j
  |¡|_ |    |_dS)zX
        This method should only be called once, before the connection is used.
        N)roÚ verify_moderrlrmÚ    cert_reqsrnÚassert_hostnamerÚosÚpathÚ
expanduserÚca_certsÚ ca_cert_dirÚ ca_cert_data)
r,rlrmrsrnrxrtrryrzrrrÚset_certs
 
zHTTPSConnection.set_certc Csœ| ¡}|j}t|ddƒr4||_| ¡d|_|j}|}|jdk    rH|j}tj     
¡t k}|rlt   d t ¡t¡d}|jdkr˜d}tt|jƒt|jƒd|_|j}t|jƒ|_|jsÒ|jsÒ|jsÒ|rÒt|dƒrÒ| ¡t||j|j|j|j|j|j||d    |_|j rt |jj!dd    |j ƒnd|jt"j#kr~t|d
dƒs~|j$dk    r~|j !¡}| %d d ¡slt   d  |¡t&¡t'||j$pz|ƒ|jt"j(kp”|j dk    |_)dS)Nr<rzWSystem time is way off (before {0}). This will probably lead to SSL verification errorsFT)Ú ssl_versionrsÚload_default_certs)    r=ÚkeyfileÚcertfilernrxryrzrpro)Ú binary_formÚcheck_hostnameÚsubjectAltNamerzëCertificate for {0} has no `subjectAltName`, falling back to check for a `commonName` for now. This feature is being removed by major browsers and deprecated by RFC 2818. (See https://github.com/urllib3/urllib3/issues/497 for details.))*r;r2r>r=r?r@r<rpÚdatetimeÚdateÚtodayÚ RECENT_DATEÚwarningsÚwarnÚformatrrorrr|rrsrrrxryrzÚhasattrr}rrlrmrnrÚ getpeercertÚsslÚ    CERT_NONErtr(rÚ_match_hostnameÚ CERT_REQUIREDrh)r,r9ÚhostnamerpÚ is_time_offÚdefault_ssl_contextÚcontextÚcertrrrrC2s’ 
ÿýû
 
þ ÿþýüû÷  ÿ
ÿ
þý
ýù    þzHTTPSConnection.connect)    NNNNNNNNN)r r r rcrdrsrxryrzr|rreÚ_GLOBAL_DEFAULT_TIMEOUTr+r{rCrrrrrkís6ö
ö
!rkc
CsLzt||ƒWn8tk
rF}zt d||¡||_‚W5d}~XYnXdS)Nz@Certificate did not match expected hostname: %s. Certificate: %s)rrÚlogÚwarningÚ
_peer_cert)r”Úasserted_hostnamer:rrrrŽ”sýrŽ):Ú
__future__rÚrerƒÚloggingrurerr7rr6r‡ÚpackagesrZpackages.six.moves.http_clientrr*rrŒÚSSLErrorr    Ú ImportErrorÚAttributeErrorÚ BaseExceptionrÚ    NameErrorÚ    ExceptionÚ
exceptionsrrrrZpackages.ssl_match_hostnamerrZ    util.ssl_rrrrrÚutilrÚ _collectionsrÚ    getLoggerr r–rcr„r†ÚcompilerDÚobjectr!rkrŽÚVerifiedHTTPSConnectionrrrrÚ<module>sL    
      
 
 
'(