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
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
U
I=®d,Tã@sÌdZddlZddlZddlmZmZddlmZddl    m
Z
ddl    m Z ddl mZddlmZdd    lmZdd
lmZdd lmZdd lmZdd lmZddlmZddlmZddlmZddlmZddlmZddlmZddl m!Z!m"Z"ddl#m$Z$m%Z%m&Z&m'Z'm(Z(m)Z)m*Z*ddl+m,Z,ddl-m.Z.ddl/m0Z0m1Z1m2Z2mZmZm3Z3m4Z4m5Z5m6Z6ddl7m8Z8zddl9m:Z:Wne;k
r–dd„Z:YnXdZ<dZ=dZ>dZ?Gd d!„d!e@ƒZAGd"d#„d#eAƒZBdS)$z‰
requests.adapters
~~~~~~~~~~~~~~~~~
 
This module contains the transport adapters that Requests uses to define
and maintain connections.
éN)Ú PoolManagerÚproxy_from_url)Ú HTTPResponse)Ú    parse_url)ÚTimeout)ÚRetry)ÚClosedPoolError)ÚConnectTimeoutError)Ú    HTTPError)Ú MaxRetryError)ÚNewConnectionError)Ú
ProxyError)Ú ProtocolError)ÚReadTimeoutError)ÚSSLError)Ú ResponseError)ÚLocationValueErroré)ÚResponse)ÚurlparseÚ
basestring)ÚDEFAULT_CA_BUNDLE_PATHÚextract_zipped_pathsÚget_encoding_from_headersÚprepend_scheme_if_neededÚget_auth_from_urlÚ urldefragauthÚ select_proxy)ÚCaseInsensitiveDict)Úextract_cookies_to_jar)    ÚConnectionErrorÚConnectTimeoutÚ ReadTimeoutrr Ú
RetryErrorÚ InvalidSchemaÚInvalidProxyURLÚ
InvalidURL)Ú_basic_auth_str)ÚSOCKSProxyManagercOs tdƒ‚dS)Nz'Missing dependencies for SOCKS support.)r$)ÚargsÚkwargs©r+úTD:\z\workplace\VsCode\pyvenv\venv\Lib\site-packages\pip/_vendor/requests/adapters.pyr(.sr(Fé
cs2eZdZdZ‡fdd„Zd dd„Zd    d
„Z‡ZS) Ú BaseAdapterzThe Base Transport Adaptercstt|ƒ ¡dS©N)Úsuperr.Ú__init__©Úself©Ú    __class__r+r,r1:szBaseAdapter.__init__FNTcCst‚dS)aCSends PreparedRequest object. Returns Response object.
 
        :param request: The :class:`PreparedRequest <PreparedRequest>` being sent.
        :param stream: (optional) Whether to stream the request content.
        :param timeout: (optional) How long to wait for the server to send
            data before giving up, as a float, or a :ref:`(connect timeout,
            read timeout) <timeouts>` tuple.
        :type timeout: float or tuple
        :param verify: (optional) Either a boolean, in which case it controls whether we verify
            the server's TLS certificate, or a string, in which case it must be a path
            to a CA bundle to use
        :param cert: (optional) Any user-provided SSL certificate to be trusted.
        :param proxies: (optional) The proxies dictionary to apply to the request.
        N©ÚNotImplementedError)r3ÚrequestÚstreamÚtimeoutÚverifyÚcertÚproxiesr+r+r,Úsend=szBaseAdapter.sendcCst‚dS)z!Cleans up adapter specific items.Nr6r2r+r+r,ÚcloseOszBaseAdapter.close)FNTNN)Ú__name__Ú
__module__Ú __qualname__Ú__doc__r1r>r?Ú __classcell__r+r+r4r,r.7s ÿ
r.cs eZdZdZdddddgZeeeef‡fdd„    Zd    d
„Z    d d „Z
efd d„Z dd„Z dd„Z dd„Zd$dd„Zdd„Zdd„Zdd„Zdd„Zd%d"d#„Z‡ZS)&Ú HTTPAdapteraThe built-in HTTP Adapter for urllib3.
 
    Provides a general-case interface for Requests sessions to contact HTTP and
    HTTPS urls by implementing the Transport Adapter interface. This class will
    usually be created by the :class:`Session <Session>` class under the
    covers.
 
    :param pool_connections: The number of urllib3 connection pools to cache.
    :param pool_maxsize: The maximum number of connections to save in the pool.
    :param max_retries: The maximum number of retries each connection
        should attempt. Note, this applies only to failed DNS lookups, socket
        connections and connection timeouts, never to requests where data has
        made it to the server. By default, Requests does not retry failed
        connections. If you need granular control over the conditions under
        which we retry a request, import urllib3's ``Retry`` class and pass
        that instead.
    :param pool_block: Whether the connection pool should block for connections.
 
    Usage::
 
      >>> import requests
      >>> s = requests.Session()
      >>> a = requests.adapters.HTTPAdapter(max_retries=3)
      >>> s.mount('http://', a)
    Ú max_retriesÚconfigÚ_pool_connectionsÚ _pool_maxsizeÚ _pool_blockcsd|tkrtddd|_n t |¡|_i|_i|_tt|ƒ ¡||_    ||_
||_ |j |||ddS)NrF)Úread©Úblock) ÚDEFAULT_RETRIESrrFÚfrom_intrGÚ proxy_managerr0rEr1rHrIrJÚinit_poolmanager)r3Úpool_connectionsÚ pool_maxsizerFÚ
pool_blockr4r+r,r1qs zHTTPAdapter.__init__cs‡fdd„ˆjDƒS)Ncsi|]}|tˆ|dƒ“qSr/)Úgetattr)Ú.0Úattrr2r+r,Ú
<dictcomp>„sz,HTTPAdapter.__getstate__.<locals>.<dictcomp>)Ú    __attrs__r2r+r2r,Ú __getstate__ƒszHTTPAdapter.__getstate__cCsDi|_i|_| ¡D]\}}t|||ƒq|j|j|j|jddS)NrL)rPrGÚitemsÚsetattrrQrHrIrJ)r3ÚstaterWÚvaluer+r+r,Ú __setstate__†s ÿzHTTPAdapter.__setstate__cKs0||_||_||_tf|||ddœ|—Ž|_dS)aInitializes a urllib3 PoolManager.
 
        This method should not be called from user code, and is only
        exposed for use when subclassing the
        :class:`HTTPAdapter <requests.adapters.HTTPAdapter>`.
 
        :param connections: The number of urllib3 connection pools to cache.
        :param maxsize: The maximum number of connections to save in the pool.
        :param block: Block when no free connections are available.
        :param pool_kwargs: Extra keyword arguments used to initialize the Pool Manager.
        T)Ú    num_poolsÚmaxsizerMÚstrictN)rHrIrJrÚ poolmanager)r3Ú connectionsrarMÚ pool_kwargsr+r+r,rQ’s ÿÿzHTTPAdapter.init_poolmanagercKs–||jkr|j|}n|| ¡ d¡r^t|ƒ\}}t|f|||j|j|jdœ|—Ž}|j|<n4| |¡}t    |f||j|j|jdœ|—Ž}|j|<|S)aÏReturn urllib3 ProxyManager for the given proxy.
 
        This method should not be called from user code, and is only
        exposed for use when subclassing the
        :class:`HTTPAdapter <requests.adapters.HTTPAdapter>`.
 
        :param proxy: The proxy to return a urllib3 ProxyManager for.
        :param proxy_kwargs: Extra keyword arguments used to configure the Proxy Manager.
        :returns: ProxyManager
        :rtype: urllib3.ProxyManager
        Úsocks)ÚusernameÚpasswordr`rarM)Ú proxy_headersr`rarM)
rPÚlowerÚ
startswithrr(rHrIrJrir)r3ÚproxyÚ proxy_kwargsÚmanagerrgrhrir+r+r,Úproxy_manager_for¦s6
  ÿúù
 
ÿûúzHTTPAdapter.proxy_manager_forcCsü| ¡ d¡rn|rnd}|dk    r"|}|s.ttƒ}|r>tj |¡sLtd |¡ƒ‚d|_    tj 
|¡sf||_ q€||_ nd|_    d|_ d|_ |røt |tƒs¤|d|_|d|_n ||_d|_|jrÔtj |j¡sÔtd     |j¡ƒ‚|jrøtj |j¡søtd
 |j¡ƒ‚dS) aAVerify a SSL certificate. This method should not be called from user
        code, and is only exposed for use when subclassing the
        :class:`HTTPAdapter <requests.adapters.HTTPAdapter>`.
 
        :param conn: The urllib3 connection object associated with the cert.
        :param url: The requested URL.
        :param verify: Either a boolean, in which case it controls whether we verify
            the server's TLS certificate, or a string, in which case it must be a path
            to a CA bundle to use
        :param cert: The SSL certificate to verify.
        ÚhttpsNTzECould not find a suitable TLS CA certificate bundle, invalid path: {}Ú CERT_REQUIREDÚ    CERT_NONErrz9Could not find the TLS certificate file, invalid path: {}z1Could not find the TLS key file, invalid path: {})rjrkrrÚosÚpathÚexistsÚIOErrorÚformatÚ    cert_reqsÚisdirÚca_certsÚ ca_cert_dirÚ
isinstancerÚ    cert_fileÚkey_file)r3ÚconnÚurlr;r<Úcert_locr+r+r,Ú cert_verifyËs> ÿ 
 
 ÿÿzHTTPAdapter.cert_verifycCs„tƒ}t|ddƒ|_tt|diƒƒ|_t|jƒ|_||_|jj|_t    |j
t ƒr^|j
  d¡|_
n|j
|_
t |j||ƒ||_||_|S)a¶Builds a :class:`Response <requests.Response>` object from a urllib3
        response. This should not be called from user code, and is only exposed
        for use when subclassing the
        :class:`HTTPAdapter <requests.adapters.HTTPAdapter>`
 
        :param req: The :class:`PreparedRequest <PreparedRequest>` used to generate the response.
        :param resp: The urllib3 response object.
        :rtype: requests.Response
        ÚstatusNÚheadersúutf-8)rrUÚ status_coderr„rÚencodingÚrawÚreasonr|r€ÚbytesÚdecoderÚcookiesr8Ú
connection)r3ÚreqÚrespÚresponser+r+r,Úbuild_responseÿs
 
 zHTTPAdapter.build_responseNcCsdt||ƒ}|rDt|dƒ}t|ƒ}|js.tdƒ‚| |¡}| |¡}nt|ƒ}| ¡}|j     |¡}|S)aŒReturns a urllib3 connection for the given URL. This should not be
        called from user code, and is only exposed for use when subclassing the
        :class:`HTTPAdapter <requests.adapters.HTTPAdapter>`.
 
        :param url: The URL to connect to.
        :param proxies: (optional) A Requests-style dictionary of proxies used on this request.
        :rtype: urllib3.ConnectionPool
        ÚhttpzFPlease check proxy URL. It is malformed and could be missing the host.)
rrrÚhostr%roÚconnection_from_urlrÚgeturlrc)r3r€r=rlÚ    proxy_urlrPrÚparsedr+r+r,Úget_connection$s    
 
 
  zHTTPAdapter.get_connectioncCs&|j ¡|j ¡D] }| ¡qdS)z¢Disposes of any internal state.
 
        Currently, this closes the PoolManager and any active ProxyManager,
        which closes any pooled connections.
        N)rcÚclearrPÚvalues)r3rlr+r+r,r??s
zHTTPAdapter.closec    Cs`t|j|ƒ}t|jƒj}|o"|dk}d}|rDt|ƒj ¡}| d¡}|j}|r\|s\t|jƒ}|S)a?Obtain the url to use when making the final request.
 
        If the message is being sent through a HTTP proxy, the full URL has to
        be used. Otherwise, we should only use the path portion of the URL.
 
        This should not be called from user code, and is only exposed for use
        when subclassing the
        :class:`HTTPAdapter <requests.adapters.HTTPAdapter>`.
 
        :param request: The :class:`PreparedRequest <PreparedRequest>` being sent.
        :param proxies: A dictionary of schemes or schemes and hosts to proxy URLs.
        :rtype: str
        rpFrf)rr€rÚschemerjrkÚpath_urlr)    r3r8r=rlr›Úis_proxied_http_requestÚusing_socks_proxyÚ proxy_schemer€r+r+r,Ú request_urlIs   
 
zHTTPAdapter.request_urlcKsdS)a"Add any headers needed by the connection. As of v2.0 this does
        nothing by default, but is left for overriding by users that subclass
        the :class:`HTTPAdapter <requests.adapters.HTTPAdapter>`.
 
        This should not be called from user code, and is only exposed for use
        when subclassing the
        :class:`HTTPAdapter <requests.adapters.HTTPAdapter>`.
 
        :param request: The :class:`PreparedRequest <PreparedRequest>` to add headers to.
        :param kwargs: The keyword arguments from the call to send().
        Nr+)r3r8r*r+r+r,Ú add_headersfs zHTTPAdapter.add_headerscCs&i}t|ƒ\}}|r"t||ƒ|d<|S)aReturns a dictionary of the headers to add to any request sent
        through a proxy. This works with urllib3 magic to ensure that they are
        correctly sent to the proxy, rather than in a tunnelled request if
        CONNECT is being used.
 
        This should not be called from user code, and is only exposed for use
        when subclassing the
        :class:`HTTPAdapter <requests.adapters.HTTPAdapter>`.
 
        :param proxy: The url of the proxy being used for this request.
        :rtype: dict
        zProxy-Authorization)rr')r3rlr„rgrhr+r+r,rits  ÿzHTTPAdapter.proxy_headersFTc Csäz| |j|¡}Wn.tk
r@}zt||d‚W5d}~XYnX| ||j||¡| ||¡}    |j||||||d|jdkpˆd|jk }
t    |t
ƒræz|\} } t | | d}Wqþt k
râ}zd  |¡} t | ƒ‚W5d}~XYqþXnt    |t ƒròn t ||d}zF|
s2|j|j|    |j|jdddd|j|d
}nt|d    ƒrD|j}|jtd
}zÚ|j|j|    d d |j ¡D]\}}| ||¡qn| ¡|jD]D}| tt|ƒƒd d… d¡¡| d¡| |¡| d¡q”| d¡z|jd d}Wntk
r| ¡}YnXtj |||ddd}Wn| !¡‚YnXWnt"t#j$fk
r~} zt%| |d‚W5d} ~ XYnZt&k
r"}z†t    |j't(ƒr¸t    |j't)ƒs¸t*||d‚t    |j't+ƒrÒt,||d‚t    |j't-ƒrìt.||d‚t    |j't/ƒrt0||d‚t%||d‚W5d}~XYn¶t1k
rP}zt%||d‚W5d}~XYnˆt-k
rz}z t.|ƒ‚W5d}~XYn^t/t2fk
rÖ}z:t    |t/ƒrªt0||d‚nt    |t3ƒrÄt4||d‚n‚W5d}~XYnX| 5||¡S)aSends PreparedRequest object. Returns Response object.
 
        :param request: The :class:`PreparedRequest <PreparedRequest>` being sent.
        :param stream: (optional) Whether to stream the request content.
        :param timeout: (optional) How long to wait for the server to send
            data before giving up, as a float, or a :ref:`(connect timeout,
            read timeout) <timeouts>` tuple.
        :type timeout: float or tuple or urllib3 Timeout object
        :param verify: (optional) Either a boolean, in which case it controls whether
            we verify the server's TLS certificate, or a string, in which case it
            must be a path to a CA bundle to use
        :param cert: (optional) Any user-provided SSL certificate to be trusted.
        :param proxies: (optional) The proxies dictionary to apply to the request.
        :rtype: requests.Response
        )r8N)r9r:r;r<r=zContent-Length)ÚconnectrKzrInvalid timeout {}. Pass a (connect, read) timeout tuple, or a single float to set both timeouts to the same valueF)
Úmethodr€Úbodyr„ÚredirectÚassert_same_hostÚpreload_contentÚdecode_contentÚretriesr:Ú
proxy_pool)r:T)Úskip_accept_encodingér…s
s0
 
)Ú    buffering)Úpoolrr§r¨)6r˜r€rr&r‚r r¡r¤r„r|ÚtupleÚ TimeoutSauceÚ
ValueErrorrwÚurlopenr£rFÚhasattrrªÚ    _get_connÚDEFAULT_POOL_TIMEOUTÚ
putrequestr[Ú    putheaderÚ
endheadersr>ÚhexÚlenÚencodeÚ getresponseÚ    TypeErrorrÚ from_httplibr?rÚsocketÚerrorr r r‰r    r r!rr#Ú _ProxyErrorr Ú    _SSLErrorrrÚ
_HTTPErrorrr"r‘)r3r8r9r:r;r<r=rÚer€Úchunkedr¢rKÚerrrÚlow_connÚheaderr^ÚiÚrr+r+r,r>Šs² 
þ
 ö
  þ
 
 
 
û
      zHTTPAdapter.send)N)FNTNN)r@rArBrCrYÚDEFAULT_POOLSIZErNÚDEFAULT_POOLBLOCKr1rZr_rQror‚r‘r˜r?r r¡rir>rDr+r+r4r,rETs*ÿþ %4%
 
rE)CrCÚos.pathrsr¿Zpip._vendor.urllib3.poolmanagerrrZpip._vendor.urllib3.responserÚpip._vendor.urllib3.utilrrr°Zpip._vendor.urllib3.util.retryrZpip._vendor.urllib3.exceptionsrr    r
rÃr r r rÁrrrrÂrrÚmodelsrÚcompatrrÚutilsrrrrrrrÚ
structuresrrŒrÚ
exceptionsr r!r"r#r$r%r&Úauthr'Z!pip._vendor.urllib3.contrib.socksr(Ú ImportErrorrÌrËrNrµÚobjectr.rEr+r+r+r,Ú<module>sF                $  ,