zmc
2023-12-22 9fdbf60165db0400c2e8e6be2dc6e88138ac719a
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
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
U
¡ý°d¨‚ã@sòdZddlZddlZddlZddlZddlZddlZddlZddlZddl    Z    ddl
Z
ddl Z ddl m Z ddlmZmZddlmZddlmZddlmZmZmZmZdd    lmZmZmZmZmZmZdd
lm Z!dd lm"Z"m#Z#m$Z$m%Z%m&Z&m'Z'm(Z(dd l)m*Z*dd l+m,Z,m-Z-m.Z.m/Z/ddl0m1Z1dZ2e 3¡Z4dddœZ5d 6e 7deddd¡¡Z8ej9dkrvdd„Z:dd„Z"dd„Z;dd „Z<dtd"d#„Z=d$d%„Z>d&d'„Z?ej@d(d)„ƒZAd*d+„ZBd,d-„ZCd.d/„ZDd0d1„ZEdud2d3„ZFd4d5„ZGd6d7„ZHd8d9„ZId:d;„ZJd<d=„ZKd>d?„ZLd@dA„ZMdBdC„ZNeOdDƒZPdEdF„ZQdGdH„ZRdIdJ„ZSdKdL„ZTdMdN„ZUdOdP„ZVej@dQdR„ƒZWdSdT„ZXdvdUdV„ZYdWdX„ZZdwdYdZ„Z[dxd\d]„Z\d^d_„Z]d`da„Z^db _dc¡Z`e`ddZae`deZbdfdg„Zcdhdi„Zddjdk„Zedldm„Zfdndo„Zgdpdq„Zhdrds„ZidS)yz”
requests.utils
~~~~~~~~~~~~~~
 
This module provides utility functions that are used within Requests
that are also useful for external consumption.
éN)Ú OrderedDict)Ú make_headersÚ    parse_urlé)Úcerts©Ú __version__)Ú_HEADER_VALIDATORS_BYTEÚ_HEADER_VALIDATORS_STRÚHEADER_VALIDATORSÚto_native_string)ÚMappingÚ
basestringÚbytesÚ
getproxiesÚgetproxies_environmentÚ integer_types)Úparse_http_list)Ú proxy_bypassÚproxy_bypass_environmentÚquoteÚstrÚunquoteÚurlparseÚ
urlunparse©Úcookiejar_from_dict)ÚFileModeWarningÚ InvalidHeaderÚ
InvalidURLÚUnrewindableBodyError)ÚCaseInsensitiveDict)z.netrcÚ_netrcéPi»)ÚhttpÚhttpsz, z,\s*T)Úaccept_encodingzaccept-encodingÚwin32c    Csêz ddl}Wntk
r"YdSXz6| |jd¡}t| |d¡dƒ}| |d¡d}Wnttfk
rtYdSX|r~|s‚dS| d¡}|D]T}|dkrªd|krªd    S|     dd
¡}|     d d ¡}|     d d¡}t
  ||t
j ¡rd    SqdS)NrFz;Software\Microsoft\Windows\CurrentVersion\Internet SettingsÚ ProxyEnableÚ ProxyOverrideú;z<local>Ú.Tz\.Ú*z.*ú?) ÚwinregÚ ImportErrorÚOpenKeyÚHKEY_CURRENT_USERÚintÚ QueryValueExÚOSErrorÚ
ValueErrorÚsplitÚreplaceÚreÚmatchÚI)Úhostr.ÚinternetSettingsÚ proxyEnableÚ proxyOverrideÚtest©r@úEd:\z\workplace\vscode\pyvenv\venv\Lib\site-packages\requests/utils.pyÚproxy_bypass_registryLs4 þ
   rBcCstƒrt|ƒSt|ƒSdS)zšReturn True, if the host should be bypassed.
 
        Checks proxy settings gathered from the environment, if specified,
        or the registry.
        N)rrrB)r;r@r@rArpsrcCst|dƒr| ¡}|S)z/Returns an internal sequence dictionary update.Úitems)ÚhasattrrC)Údr@r@rAÚdict_to_sequence|s
rFc    Cs0d}d}t|dƒrt|ƒ}nft|dƒr.|j}nTt|dƒr‚z | ¡}Wntjtfk
r^Yn$Xt |¡j}d|j    kr‚t
  dt ¡t|dƒrz |  ¡}Wn tk
rº|dk    r¶|}YnZXt|dƒr|dkrz&| dd    ¡|  ¡}| |pòd¡Wntk
rd}YnX|dkr"d}td||ƒS)
NrÚ__len__ÚlenÚfilenoÚba%Requests has determined the content-length for this request using the binary size of the file: however, the file has been opened in text mode (i.e. without the 'b' flag in the mode). This may lead to an incorrect content-length. In Requests 3.0, support will be removed for files in text mode.ÚtellÚseeké)rDrHrIÚioÚUnsupportedOperationÚAttributeErrorÚosÚfstatÚst_sizeÚmodeÚwarningsÚwarnrrKr4rLÚmax)ÚoÚ total_lengthÚcurrent_positionrIr@r@rAÚ    super_len…sB
 
 
 
 
÷  
 
 
r[Fc    CsLtj d¡}|dk    r|f}ndd„tDƒ}zddlm}m}d}|D]D}ztj |¡}Wntk
rtYWdSXtj     |¡rF|}qŒqF|dkršWdSt
|ƒ}    d}
t |t ƒrº|
  d¡}
|    j |
¡d} z<||ƒ | ¡} | r| drìdnd    } | | | d
fWWSWn"|tfk
r(|r$‚YnXWnttfk
rFYnXdS) z;Returns the Requests tuple auth for a given url from netrc.ZNETRCNcss|]}d|›VqdS)z~/Nr@)Ú.0Úfr@r@rAÚ    <genexpr>Îsz!get_netrc_auth.<locals>.<genexpr>r)ÚNetrcParseErrorÚnetrcó:ÚasciirrM)rQÚenvironÚgetÚ NETRC_FILESr`r_ÚpathÚ
expanduserÚKeyErrorÚexistsrÚ
isinstancerÚdecodeÚnetlocr6Úauthenticatorsr4r/rP)ÚurlÚ raise_errorsZ
netrc_fileZnetrc_locationsr_r`Ú
netrc_pathr]ÚlocÚriÚsplitstrr;r"Úlogin_ir@r@rAÚget_netrc_authÇs@   
 
 rucCsBt|ddƒ}|r>t|tƒr>|ddkr>|ddkr>tj |¡SdS)z0Tries to guess the filename of the given object.ÚnameNrú<éÿÿÿÿú>)ÚgetattrrjrrQrfÚbasename)Úobjrvr@r@rAÚguess_filenames &r}c    CsÒtj |¡r|Stj |¡\}}|rVtj |¡sVtj |¡\}}|sFqVd ||g¡}q t |¡sd|St |¡}|| ¡kr~|St     
¡}tj || d¡d¡}tj |¡sÎt |ƒ}|  |  |¡¡W5QRX|S)zÄReplace nonexistent paths that look like they refer to a member of a zip
    archive with the location of an extracted copy of the target, or else
    just return the provided path unchanged.
    ú/rx)rQrfrir6ÚjoinÚzipfileÚ
is_zipfileÚZipFileÚnamelistÚtempfileÚ
gettempdirÚ atomic_openÚwriteÚread)rfÚarchiveÚmemberÚprefixÚzip_fileÚtmpÚextracted_pathZ file_handlerr@r@rAÚextract_zipped_pathss& 
 
 
rc    csltjtj |¡d\}}z.t |d¡ }|VW5QRXt ||¡Wn tk
rft |¡‚YnXdS)z-Write a file to the disk in an atomic fashion)ÚdirÚwbN)    r„ÚmkstemprQrfÚdirnameÚfdopenr7Ú BaseExceptionÚremove)ÚfilenameZtmp_descriptorZtmp_nameZ tmp_handlerr@r@rAr†,s
r†cCs.|dkr dSt|ttttfƒr&tdƒ‚t|ƒS)aTake an object and test to see if it can be represented as a
    dictionary. Unless it can not be represented as such, return an
    OrderedDict, e.g.,
 
    ::
 
        >>> from_key_val_list([('key', 'val')])
        OrderedDict([('key', 'val')])
        >>> from_key_val_list('string')
        Traceback (most recent call last):
        ...
        ValueError: cannot encode objects that are not 2-tuples
        >>> from_key_val_list({'key': 'val'})
        OrderedDict([('key', 'val')])
 
    :rtype: OrderedDict
    Nú+cannot encode objects that are not 2-tuples)rjrrÚboolr2r5r©Úvaluer@r@rAÚfrom_key_val_list9s
rœcCs@|dkr dSt|ttttfƒr&tdƒ‚t|tƒr8| ¡}t|ƒS)aÂTake an object and test to see if it can be represented as a
    dictionary. If it can be, return a list of tuples, e.g.,
 
    ::
 
        >>> to_key_val_list([('key', 'val')])
        [('key', 'val')]
        >>> to_key_val_list({'key': 'val'})
        [('key', 'val')]
        >>> to_key_val_list('string')
        Traceback (most recent call last):
        ...
        ValueError: cannot encode objects that are not 2-tuples
 
    :rtype: list
    Nr˜)    rjrrr™r2r5r rCÚlistršr@r@rAÚto_key_val_listTs
ržcCsXg}t|ƒD]F}|dd…|dd…kr4dkrHnnt|dd…ƒ}| |¡q |S)aParse lists as described by RFC 2068 Section 2.
 
    In particular, parse comma-separated lists where the elements of
    the list may include quoted-strings.  A quoted-string could
    contain a comma.  A non-quoted string could have quotes in the
    middle.  Quotes are removed automatically after parsing.
 
    It basically works like :func:`parse_set_header` just that items
    may appear multiple times and case sensitivity is preserved.
 
    The return value is a standard :class:`list`:
 
    >>> parse_list_header('token, "quoted value"')
    ['token', 'quoted value']
 
    To create a header from the :class:`list` again, use the
    :func:`dump_header` function.
 
    :param value: a string with a list header.
    :return: :class:`list`
    :rtype: list
    Nrrxú")Ú_parse_list_headerÚunquote_header_valueÚappend)r›ÚresultÚitemr@r@rAÚparse_list_headerrs  ( r¥cCsxi}t|ƒD]f}d|kr"d||<q | dd¡\}}|dd…|dd…krVdkrjnnt|dd…ƒ}|||<q |S)a^Parse lists of key, value pairs as described by RFC 2068 Section 2 and
    convert them into a python dict:
 
    >>> d = parse_dict_header('foo="is a fish", bar="as well"')
    >>> type(d) is dict
    True
    >>> sorted(d.items())
    [('bar', 'as well'), ('foo', 'is a fish')]
 
    If there is no value for a key it will be `None`:
 
    >>> parse_dict_header('key_without_value')
    {'key_without_value': None}
 
    To create a header from the :class:`dict` again, use the
    :func:`dump_header` function.
 
    :param value: a string with a dict header.
    :return: :class:`dict`
    :rtype: dict
    ú=NrrxrŸ)r r6r¡)r›r£r¤rvr@r@rAÚparse_dict_header’s (
r§cCs\|rX|d|dkr dkrXnn4|dd…}|rD|dd…dkrX| dd¡ d    d¡S|S)
zçUnquotes a header value.  (Reversal of :func:`quote_header_value`).
    This does not use the real unquoting but what browsers are actually
    using for quoting.
 
    :param value: the header value to unquote.
    :rtype: str
    rrxrŸrNrMz\\ú\z\")r7)r›Ú is_filenamer@r@rAr¡µs
$ r¡cCsi}|D]}|j||j<q|S)z€Returns a key/value dictionary from a CookieJar.
 
    :param cj: CookieJar object to extract cookies from.
    :rtype: dict
    )r›rv)ÚcjÚ cookie_dictÚcookier@r@rAÚdict_from_cookiejarÎsr­cCs
t||ƒS)zÂReturns a CookieJar from a key/value dictionary.
 
    :param cj: CookieJar to insert cookies into.
    :param cookie_dict: Dict of key/values to insert into CookieJar.
    :rtype: CookieJar
    r)rªr«r@r@rAÚadd_dict_to_cookiejarÝsr®cCsTt dt¡tjdtjd}tjdtjd}t d¡}| |¡| |¡| |¡S)zlReturns encodings from given content string.
 
    :param content: bytestring to extract encodings from.
    z¤In requests 3.0, get_encodings_from_content will be removed. For more information, please see the discussion on issue #2266. (This warning should only appear once.)z!<meta.*?charset=["\']*(.+?)["\'>])Úflagsz+<meta.*?content=["\']*;?charset=(.+?)["\'>]z$^<\?xml.*?encoding=["\']*(.+?)["\'>])rUrVÚDeprecationWarningr8Úcompiler:Úfindall)ÚcontentÚ
charset_reÚ    pragma_reÚxml_rer@r@rAÚget_encodings_from_contentèsú    
ÿþÿr·c
Csš| d¡}|d ¡|dd…}}i}d}|D]`}| ¡}|r0|d}}| d¡}    |    dkr„|d|    … |¡}||    dd… |¡}||| ¡<q0||fS)    z¦Returns content type and parameters from given header
 
    :param header: string
    :return: tuple containing content type and dictionary of
         parameters
    r*rrNz"' Tr¦rx)r6ÚstripÚfindÚlower)
ÚheaderÚtokensÚ content_typeÚparamsÚ params_dictÚitems_to_stripÚparamÚkeyr›Úindex_of_equalsr@r@rAÚ_parse_content_type_headers
 
 
rÄcCsP| d¡}|sdSt|ƒ\}}d|kr4|d d¡Sd|kr@dSd|krLdSdS)    z}Returns encodings from given HTTP Header Dict.
 
    :param headers: dictionary to extract encoding from.
    :rtype: str
    z content-typeNÚcharsetz'"Útextz
ISO-8859-1zapplication/jsonúutf-8)rdrÄr¸)Úheadersr½r¾r@r@rAÚget_encoding_from_headerss
 rÉccsd|jdkr|EdHdSt |j¡dd}|D]}| |¡}|r.|Vq.|jddd}|r`|VdS)zStream decodes an iterator.Nr7©ÚerrorsóT)Úfinal)ÚencodingÚcodecsÚgetincrementaldecoderrk)ÚiteratorÚrÚdecoderÚchunkÚrvr@r@rAÚstream_decode_response_unicode3s
 
 
rÖccsHd}|dks|dkrt|ƒ}|t|ƒkrD||||…V||7}qdS)z Iterate over slices of a string.rN)rH)ÚstringÚ slice_lengthÚposr@r@rAÚ iter_slicesDs  rÚcCs~t dt¡g}t|jƒ}|rLzt|j|ƒWStk
rJ| |¡YnXzt|j|ddWSt    k
rx|jYSXdS)zâReturns the requested content back in unicode.
 
    :param r: Response object to get unicode content from.
 
    Tried:
 
    1. charset from content-type
    2. fall back and replace all unicode characters
 
    :rtype: str
    z£In requests 3.0, get_unicode_from_response will be removed. For more information, please see the discussion on issue #2266. (This warning should only appear once.)r7rÊN)
rUrVr°rÉrÈrr³Ú UnicodeErrorr¢Ú    TypeError)rÒÚtried_encodingsrÎr@r@rAÚget_unicode_from_responseNs ú    
rÞzBABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-._~c    CsÌ| d¡}tdt|ƒƒD]¨}||dd…}t|ƒdkr®| ¡r®ztt|dƒƒ}Wn$tk
rvtd|›dƒ‚YnX|tkrš|||dd…||<qÀd||›||<qd||›||<qd         |¡S)
z¨Un-escape any percent-escape sequences in a URI that are unreserved
    characters. This leaves all reserved, illegal and non-ASCII bytes encoded.
 
    :rtype: str
    ú%rrrMéz"Invalid percent-escape sequence: 'ú'NÚ)
r6ÚrangerHÚisalnumÚchrr2r5rÚUNRESERVED_SETr)ÚuriÚpartsÚiÚhÚcr@r@rAÚunquote_unreserved{s
rìcCs@d}d}ztt|ƒ|dWStk
r:t||dYSXdS)z¬Re-quote the given URI.
 
    This function passes the given URI through an unquote/quote cycle to
    ensure that it is fully and consistently quoted.
 
    :rtype: str
    z!#$%&'()*+,/:;=?@[]~z!#$&'()*+,/:;=?@[]~)ÚsafeN)rrìr)rçÚsafe_with_percentÚsafe_without_percentr@r@rAÚ requote_uri“s rðcCslt dt |¡¡d}| d¡\}}t dt tt|ƒƒ¡¡d}t dt |¡¡d|@}||@||@kS)zïThis function allows you to check if an IP belongs to a network subnet
 
    Example: returns True if ip = 192.168.1.1 and net = 192.168.1.0/24
             returns False if ip = 192.168.1.1 and net = 192.168.100.0/24
 
    :rtype: bool
    z=Lrr~)ÚstructÚunpackÚsocketÚ    inet_atonr6Údotted_netmaskr2)ÚipÚnetÚipaddrÚnetaddrÚbitsÚnetmaskÚnetworkr@r@rAÚaddress_in_network©s
rýcCs&ddd|>dA}t t d|¡¡S)zConverts mask from /xx format to xxx.xxx.xxx.xxx
 
    Example: if mask is 24 function returns 255.255.255.0
 
    :rtype: str
    lÿÿré z>I)róÚ    inet_ntoarñÚpack)Úmaskrúr@r@rArõ¸srõcCs*zt |¡Wntk
r$YdSXdS)z
    :rtype: bool
    FT)rórôr4)Ú    string_ipr@r@rAÚis_ipv4_addressÃs
rcCsŠ| d¡dkr‚zt| d¡dƒ}Wntk
r:YdSX|dksL|dkrPdSzt | d¡d¡Wq†tk
r~YdSXndSdS)zV
    Very simple check of the cidr format in no_proxy variable.
 
    :rtype: bool
    r~rFrþrT)Úcountr2r6r5rórôr4)Ústring_networkrr@r@rAÚ is_valid_cidrÎs
rc    csT|dk    }|r"tj |¡}|tj|<z
dVW5|rN|dkrDtj|=n
|tj|<XdS)zÎSet the environment variable 'env_name' to 'value'
 
    Save previous value, yield, and then restore the previous value stored in
    the environment variable 'env_name'.
 
    If 'value' is None, do nothingN)rQrcrd)Úenv_namer›Ú value_changedÚ    old_valuer@r@rAÚ set_environæs 
 
 
r
c    
Cs*dd„}|}|dkr|dƒ}t|ƒ}|jdkr2dS|rÖdd„| dd    ¡ d
¡Dƒ}t|jƒr”|D]0}t|ƒr€t|j|ƒrdSq`|j|kr`dSq`nB|j}|jr°|d |j›7}|D] }|j |¡sÎ| |¡r´dSq´t    d|ƒ6zt
|jƒ}Wn t t j fk
rd }YnXW5QRX|r&dSd S) zL
    Returns whether we should bypass proxies or not.
 
    :rtype: bool
    cSstj |¡ptj | ¡¡S©N)rQrcrdÚupper)rÂr@r@rAÚ    get_proxysz(should_bypass_proxies.<locals>.get_proxyNÚno_proxyTcss|]}|r|VqdSr r@)r\r;r@r@rAr^sz(should_bypass_proxies.<locals>.<genexpr>ú râú,ú:F)rÚhostnamer7r6rrrýÚportÚendswithr
rrÜróÚgaierror)    rnrr Ú no_proxy_argÚparsedÚproxy_ipÚhost_with_portr;Úbypassr@r@rAÚshould_bypass_proxiesüs<
 
 
 
 rcCst||driStƒSdS)zA
    Return a dict of environment proxies.
 
    :rtype: dict
    ©rN)rr)rnrr@r@rAÚget_environ_proxies8s rcCst|pi}t|ƒ}|jdkr.| |j| d¡¡S|jd|j|jd|jdg}d}|D]}||krV||}qpqV|S)z­Select a proxy for the url, if applicable.
 
    :param url: The url being for the request
    :param proxies: A dictionary of schemes or schemes and hosts to proxy URLs
    NÚallz://zall://)rrrdÚscheme)rnÚproxiesÚurlpartsÚ
proxy_keysÚproxyÚ    proxy_keyr@r@rAÚ select_proxyDs
ür%c    Cst|dk    r |ni}|j}t|ƒj}| d¡}| ¡}|rpt||dspt||d}| || d¡¡}|rp| ||¡|S)a¨This method takes proxy information from a request and configuration
    input to resolve a mapping of target proxies. This will consider settings
    such a NO_PROXY to strip proxy configurations.
 
    :param request: Request or PreparedRequest
    :param proxies: A dictionary of schemes or schemes and hosts to proxy URLs
    :param trust_env: Boolean declaring whether to trust environment configs
 
    :rtype: dict
    Nrrr)rnrrrdÚcopyrrÚ
setdefault)    Úrequestr Ú    trust_envrnrrÚ new_proxiesÚenviron_proxiesr#r@r@rAÚresolve_proxies^s 
 
  r,úpython-requestscCs|›dt›S)zO
    Return a string representing the default user agent.
 
    :rtype: str
    r~r)rvr@r@rAÚdefault_user_agentysr.cCsttƒtdddœƒS)z9
    :rtype: requests.structures.CaseInsensitiveDict
    z*/*z
keep-alive)z
User-AgentzAccept-EncodingÚAcceptÚ
Connection)r!r.ÚDEFAULT_ACCEPT_ENCODINGr@r@r@rAÚdefault_headers‚süÿr2c    
CsÎg}d}| |¡}|s|St d|¡D]¢}z| dd¡\}}Wntk
r\|d}}YnXd| d¡i}| d¡D]F}z| d¡\}}Wntk
r¦Yq¾YnX| |¡|| |¡<qv| |¡q&|S)    z¼Return a list of parsed link headers proxies.
 
    i.e. Link: <http:/.../front.jpeg>; rel=front; type="image/jpeg",<http://.../back.jpeg>; rel=back;type="image/jpeg"
 
    :rtype: list
    z '"z, *<r*rrârnz<> '"r¦)r¸r8r6r5r¢)    r›ÚlinksÚ replace_charsÚvalrnr¾ÚlinkrÁrÂr@r@rAÚparse_header_linkss&
  r7úrbrMécCsÐ|dd…}|tjtjfkr dS|dd…tjkr6dS|dd…tjtjfkrRdS| t¡}|dkrhd    S|dkrœ|ddd…tkr†d
S|d dd…tkrœd S|dkrÌ|dd…t    kr¸d S|d d…t    krÌdSdS)z
    :rtype: str
    Nézutf-32r9z    utf-8-sigrMzutf-16rrÇz    utf-16-berz    utf-16-lez    utf-32-bez    utf-32-le)
rÏÚ BOM_UTF32_LEÚ BOM_UTF32_BEÚBOM_UTF8Ú BOM_UTF16_LEÚ BOM_UTF16_BErÚ_nullÚ_null2Ú_null3)ÚdataÚsampleÚ    nullcountr@r@rAÚguess_json_utf»s* 
rFc Cslt|ƒ}|\}}}}}}}    |j}
|
s.||
}
}|r@d ||
g¡}
|dkrL|}|dkrXd}t||
|d||    fƒS)zªGiven a URL that may or may not have a scheme, prepend the given scheme.
    Does not replace a present scheme with the one provided as an argument.
 
    :rtype: str
    ú@Nrâ)rrlrr) rnÚ
new_schemerrÚauthr;rrfÚqueryÚfragmentrlr@r@rAÚprepend_scheme_if_neededÛs
rLc    CsBt|ƒ}zt|jƒt|jƒf}Wnttfk
r<d}YnX|S)z{Given a url with authentication components, extract them into a tuple of
    username,password.
 
    :rtype: (str,str)
    )rârâ)rrÚusernameÚpasswordrPrÜ)rnrrIr@r@rAÚget_auth_from_urløs 
rOcCs$|\}}t||dƒt||dƒdS)z§Verifies that header parts don't contain leading whitespace
    reserved characters, or return characters.
 
    :param header: tuple, in the format (name, value).
    rrN)Ú_validate_header_part)r»rvr›r@r@rAÚcheck_header_validitys rQcCsxt|tƒrt|}n2t|tƒr(t|}ntd|›d|›dt|ƒ›ƒ‚| |¡st|dkr\dnd}td|›d|›ƒ‚dS)    Nz Header part (z) from z# must be of type str or bytes, not rrvr›zSInvalid leading whitespace, reserved character(s), or returncharacter(s) in header z: )rjrr
rr    rÚtyper9)r»Z header_partZheader_validator_indexZ    validatorZ header_kindr@r@rArPs
 
 
 
ÿ
ÿrPcCsFt|ƒ\}}}}}}|s"||}}| dd¡d}t|||||dfƒS)zW
    Given a url remove the fragment and the authentication part.
 
    :rtype: str
    rGrrxrâ)rÚrsplitr)rnrrlrfr¾rJrKr@r@rAÚ urldefragauth&s
 
rTcCs\t|jddƒ}|dk    rPt|jtƒrPz||jƒWqXtk
rLtdƒ‚YqXXntdƒ‚dS)zfMove file pointer back to its recorded starting position
    so it can be read again on redirect.
    rLNz;An error occurred when rewinding request body for redirect.z+Unable to rewind request body for redirect.)rzÚbodyrjÚ_body_positionrr4r )Úprepared_requestÚ    body_seekr@r@rAÚ rewind_body7s
ÿÿ rY)F)F)N)T)r-)jÚ__doc__rÏÚ
contextlibrNrQr8rórñÚsysr„rUr€Ú collectionsrZ urllib3.utilrrrârrÚ_internal_utilsr    r
r r Úcompatr rrrrrrr rrrrrrrÚcookiesrÚ
exceptionsrrrr Ú
structuresr!reÚwhereÚDEFAULT_CA_BUNDLE_PATHÚ DEFAULT_PORTSrr6r1ÚplatformrBrFr[rur}rÚcontextmanagerr†rœržr¥r§r¡r­r®r·rÄrÉrÖrÚrÞÚ    frozensetrærìrðrýrõrrr
rrr%r,r.r2r7Úencoder@rArBrFrLrOrQrPrTrYr@r@r@rAÚ<module>sž     $      
ÿ $     B
9%
 #
 
(ÿ  
<
 
 
    &