bgADddlmZddlZddlmZddlmZmZddlm Z ej rddl m Z Gdde Z d d gZejd Zejd Zejd Zejd ejeefejejeefdfZGddeZddZGdd ejeefejeefZGddejejeefZGdd ejeefZ dS)) annotationsN) OrderedDict)Enumauto)RLock)ProtocolceZdZddZd dZdS) HasGettableStringKeysreturntyping.Iterator[str]cdSNselfs K/opt/cloudlinux/venv/lib64/python3.11/site-packages/urllib3/_collections.pykeyszHasGettableStringKeys.keys CkeystrcdSrrrrs r __getitem__z!HasGettableStringKeys.__getitem__rrNr r rrr r)__name__ __module__ __qualname__rrrrrr r s<          rr RecentlyUsedContainerHTTPHeaderDict_KT_VT_DTc"eZdZeZdS) _SentinelN)rrrr not_passedrrrr&r&'sJJJrr& potentialobjectr ValidHTTPHeaderSource | Nonect|tr|St|tjr1tjtjt t f|St|tjrAtjtjtjt t f|St|dr%t|drtjd|SdS)Nrrr ) isinstancer!typingMappingcastrIterableTuplehasattr)r(s r%ensure_can_construct_http_header_dictr3+s)^,, Iv~ . . {6>#s(3Y??? Iv / /{6?6<S+ABINNN F # # =(I(I{2I>>>trceZdZUdZded<ded<ded<ded < ddfd ZddZd dZd!dZd"dZ d#dZ d$dZ d%dZ xZ S)&r a Provides a thread-safe dict-like container which maintains up to ``maxsize`` keys while throwing away the least-recently-used keys beyond ``maxsize``. :param maxsize: Maximum number of recent elements to retain. :param dispose_func: Every time an item is evicted from the container, ``dispose_func(value)`` is called. Callback which will get called ztyping.OrderedDict[_KT, _VT] _containerint_maxsize#typing.Callable[[_VT], None] | None dispose_funcrlock Nmaxsizer Nonect||_||_t |_t |_dSr)super__init__r7r9rr5rr:)rr<r9 __class__s rr@zRecentlyUsedContainer.__init__RsD  (%--GG rrr"r#c|j5|j|}||j|<|cdddS#1swxYwYdSr)r:r5pop)rritems rrz!RecentlyUsedContainer.__getitem__]s Y  ?&&s++D#'DOC                    &;??valuecd}|j5 ||j|f}||j|<nR#t$rE||j|<t |j|jkr|jd}YnwxYwdddn #1swxYwY|#|jr|\}}||dSdSdS)NF)last)r:r5rCKeyErrorlenr7popitemr9)rrrF evicted_item_ evicted_values r __setitem__z!RecentlyUsedContainer.__setitem__dsH Y G G G #DO$7$7$<$<< ',$$ G G G(-$t''$-77$(?#:#:#:#F#FL G G G G G G G G G G G G G G G G&  #(9 #+ A}   m , , , , , $ # # #s2B&3BA B?BBBBBc|j5|j|}dddn #1swxYwY|jr||dSdSr)r:r5rCr9)rrrFs r __delitem__z!RecentlyUsedContainer.__delitem__}s Y - -O'',,E - - - - - - - - - - - - - - -   %   e $ $ $ $ $ % %s /33cl|j5t|jcdddS#1swxYwYdSr)r:rJr5rs r__len__zRecentlyUsedContainer.__len__s{ Y ( (t'' ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( (s )--typing.NoReturnc td)Nz7Iteration over this class is unlikely to be threadsafe.)NotImplementedErrorrs r__iter__zRecentlyUsedContainer.__iter__s! E   rc|j5t|j}|jdddn #1swxYwY|jr|D]}||dSdSr)r:listr5valuesclearr9)rrZrFs rr[zRecentlyUsedContainer.clears Y $ $$/002233F O ! ! # # # $ $ $ $ $ $ $ $ $ $ $ $ $ $ $   ) ) )!!%(((( ) ) ) )sAAAAset[_KT]c|j5t|jcdddS#1swxYwYdSr)r:setr5rrs rrzRecentlyUsedContainer.keyss Y / /t++--.. / / / / / / / / / / / / / / / / / /rE)r;N)r<r6r9r8r r=)rr"r r#)rr"rFr#r r=)rr"r r=r r6)r rT)r r=)r r\)rrr__doc____annotations__r@rrOrQrSrWr[r __classcell__rAs@rr r ?s  -,,,MMM5555KKK<@       ----2%%%%((((    ))))////////rc>eZdZUdZded<ddZdd Zdd ZddZdS)HTTPHeaderDictItemViewa HTTPHeaderDict is unusual for a Mapping[str, str] in that it has two modes of address. If we directly try to get an item with a particular name, we will get a string back that is the concatenated version of all the values: >>> d['X-Header-Name'] 'Value1, Value2, Value3' However, if we iterate over an HTTPHeaderDict's items, we will optionally combine these values based on whether combine=True was called when building up the dictionary >>> d = HTTPHeaderDict({"A": "1", "B": "foo"}) >>> d.add("A", "2", combine=True) >>> d.add("B", "bar") >>> list(d.items()) [ ('A', '1, 2'), ('B', 'foo'), ('B', 'bar'), ] This class conforms to the interface required by the MutableMapping ABC while also giving us the nonstandard iteration behavior we want; items with duplicate keys, ordered by time of first insertion. r!_headersheadersr r=c||_dSr)rf)rrgs rr@zHTTPHeaderDictItemView.__init__s  rr6chtt|jSr)rJrYrf iteritemsrs rrSzHTTPHeaderDictItemView.__len__s&4 //1122333r typing.Iterator[tuple[str, str]]c4|jSr)rfrjrs rrWzHTTPHeaderDictItemView.__iter__s}&&(((rrDr)boolct|tr]t|dkrJ|\}}t|tr0t|tr|j||SdS)NF)r,tuplerJrrf_has_value_for_header)rrD passed_key passed_vals r __contains__z#HTTPHeaderDictItemView.__contains__so dE " " Ss4yyA~~%) "J *c** Sz*c/J/J S}:::zRRRurN)rgr!r r=r_r rk)rDr)r rm) rrrr`rar@rSrWrtrrrreres~8    4444))))rrecXeZdZUdZded<d;d<fd Zd=dZd>dZd?dZd@dZ dAdBfd Z dCdZ dCdZ dDdZ dEdZd?dZdd dFd"ZdGd%ZejdHd'ZejdId*ZejfdJd,ZeZeZeZeZdKd-ZdLd.ZdMd/ZdNd1ZdNd2ZdOd4Z dPd7Z!dQd8Z"dQd9Z#dQd:Z$xZ%S)Rr!ap :param headers: An iterable of field-value pairs. Must not contain multiple field names when compared case-insensitively. :param kwargs: Additional field-value pairs to pass in to ``dict.update``. A ``dict`` like container for storing HTTP Headers. Field names are stored and compared case-insensitively in compliance with RFC 7230. Iteration provides the first case-sensitive key seen for each case-insensitive pair. Using ``__setitem__`` syntax overwrites fields that compare equal case-insensitively in order to maintain ``dict``'s api. For fields that compare equal, instead create a new ``HTTPHeaderDict`` and use ``.add`` in a loop. If multiple fields that are equal case-insensitively are passed to the constructor or ``.update``, the behavior is undefined and some will be lost. >>> headers = HTTPHeaderDict() >>> headers.add('Set-Cookie', 'foo=bar') >>> headers.add('set-cookie', 'baz=quxx') >>> headers['content-length'] = '7' >>> headers['SET-cookie'] 'foo=bar, baz=quxx' >>> headers['Content-Length'] '7' z%typing.MutableMapping[str, list[str]]r5Nrgr*kwargsrc  ti|_|@t|tr||n|||r||dSdSr)r?r@r5r,r! _copy_fromextend)rrgrwrAs rr@zHTTPHeaderDict.__init__s   '>22 %(((( G$$$  KK       rrvalr r=ct|tr|d}||g|j|<dS)Nlatin-1)r,bytesdecoder5lowerrrr{s rrOzHTTPHeaderDict.__setitem__sC c5 ! ! (**Y''C(+Sz $$$rcz|j|}d|ddS)N, r5rjoinrs rrzHTTPHeaderDict.__getitem__s0ociikk*yyQRR!!!rc:|j|=dSrr5rrs rrQzHTTPHeaderDict.__delitem__s OCIIKK ( ( (rr)rmcft|tr||jvSdS)NF)r,rrr5rs rrtzHTTPHeaderDict.__contains__s. c3   299;;$/1 1urdefaultcHt||Sr)r? setdefault)rrrrAs rrzHTTPHeaderDict.setdefault sww!!#w///rotherct|}|dSt||}d|Dd|DkS)NFc>i|]\}}||Srr.0kvs r z)HTTPHeaderDict.__eq__..s&;;;A 1;;;rc>i|]\}}||Srrrs rrz)HTTPHeaderDict.__eq__..s9@ @ @ !QAGGIIq@ @ @ r)r3type itermerged)rrmaybe_constructableother_as_http_header_dicts r__eq__zHTTPHeaderDict.__eq__sCEJJ  &5(2T 3F(G(G %;;):):;;;@ @ %>%I%I%K%K@ @ @   rc.|| Sr)r)rrs r__ne__zHTTPHeaderDict.__ne__s;;u%%%%rr6c*t|jSr)rJr5rs rrSzHTTPHeaderDict.__len__s4?###rr c#VK|jD] }|dV dS)Nr)r5rZ)rvalss rrWzHTTPHeaderDict.__iter__!s<O**,,  Dq'MMMM  rc0 ||=dS#t$rYdSwxYwr)rIrs rdiscardzHTTPHeaderDict.discard&s4 S     DD s  F)combinercJt|tr|d}|}||g}|j||}||urAt |dksJ|r|ddz|z|d<dS||dSdS)aAdds a (name, value) pair, doesn't overwrite the value if it already exists. If this is called with combine=True, instead of adding a new header value as a distinct item during iteration, this will instead append the value to any existing header value with a comma. If no existing header value exists for the key, then the value will simply be added, ignoring the combine parameter. >>> headers = HTTPHeaderDict(foo='bar') >>> headers.add('Foo', 'baz') >>> headers['foo'] 'bar, baz' >>> list(headers.items()) [('foo', 'bar'), ('foo', 'baz')] >>> headers.add('foo', 'quz', combine=True) >>> list(headers.items()) [('foo', 'bar, baz, quz')] r}rorN)r,r~rrr5rrJappend)rrr{r key_lowernew_valsrs raddzHTTPHeaderDict.add,s( c5 ! ! (**Y''CIIKK :)))X>> 4  t99>>>> !8d?S0R C      rargsValidHTTPHeaderSourcect|dkr tdt|dt|dkr|dnd}t|tr2|D]\}}|||nt|t jr1|D]\}}|||nt|t j r`t j t j t j ttf|}|D]\}}|||nSt|drCt|dr3|D]}|||||D]\}}|||dS) zGeneric import function for any type of header-like object. Adapted version of MutableMapping.update in order to insert items with self.add instead of self.__setitem__ rz/extend() takes at most 1 positional arguments (z given)rrrrN)rJ TypeErrorr,r!rjrr-r.itemsr0r/r1rr2r)rrrwrrr{rFs rrzzHTTPHeaderDict.extendOs t99q==T#d))TTT t99>>Qr e^ , , *!OO-- # #Sc"""" # v~ . . *!KKMM # #Sc"""" # v / / *K S#X0F GOOE# % % Ue$$$$ % UF # # *}(E(E * zz|| * *eCj)))) ,,.. ! !JC HHS%  ! !r list[str]cdSrrrs rgetlistzHTTPHeaderDict.getlistp rr$list[str] | _DTcdSrr)rrrs rrzHTTPHeaderDict.getlisttrr_Sentinel | _DTc |j|}|ddS#t$r|tjurgcYS|cYSwxYw)zmReturns a list of all the values for the named field. Returns an empty list if the key doesn't exist.rN)r5rrIr&r')rrrrs rrzHTTPHeaderDict.getlistxsg ?399;;/D8O   )... NNN  s+A A  A ctt|jdt|dS)N())rrdictrrs r__repr__zHTTPHeaderDict.__repr__s4t**%BBT__->->(?(?BBBBrcx|D]6}||}|g||j|<7dSr)rr5r)rrrr{s rryzHTTPHeaderDict._copy_fromsI 7 7C--$$C,/;#;DOCIIKK ( ( 7 7rc^t|}|||Sr)rry)rclones rcopyzHTTPHeaderDict.copys,T   rrkc#K|D]:}|j|}|ddD]}|d|fV;dS)z8Iterate over all header lines, including duplicate ones.rNrr)rrrr{s rrjzHTTPHeaderDict.iteritemssf # #C?399;;/DABBx # #1gsl"""" # # #rc#K|D]H}|j|}|dd|ddfVIdS)z:Iterate over all headers, merging duplicate ones together.rrrNrrs rrzHTTPHeaderDict.itermergeds_ - -C/#))++.Ca&$))CG,,, , , , , - -rrec t|Sr)rers rrzHTTPHeaderDict.itemss%d+++r header_namepotential_valuec`||vr)||j|ddvSdS)NrFr)rrrs rrqz$HTTPHeaderDict._has_value_for_headers9 $  "dok6G6G6I6I&J122&NN Nurc`t|}|tS|||Sr)r3NotImplementedrz)rrrs r__ior__zHTTPHeaderDict.__ior__s7DEJJ  &! ! '((( rct|}|tS|}|||Sr)r3rrrzrrrresults r__or__zHTTPHeaderDict.__or__sDDEJJ  &! ! )*** rct|}|tSt||}|||Sr)r3rrrzrs r__ror__zHTTPHeaderDict.__ror__sLDEJJ  &! !d/00 d rr)rgr*rwr)rrr{rr r=r)rrr r=)rr)r rm)r)rrrrr r)rr)r rmr_r)rrr{rrrmr r=)rrrwrr r=)rrr r)rrrr$r r)rrrrr r)r r)rr!r r=)r r!ru)r re)rrrrr rm)rr)r r!)&rrrr`rar@rOrrQrtrrrrSrWrrrzr-overloadrr&r' getheadersgetallmatchingheadersigetget_allrryrrjrrrqrrrrbrcs@rr!r!sB6555        2222 """")))) 0000000     &&&&$$$$  :?!!!!!!!!!!!!F!!!!B _   _  _   _ 4=3G&J# DGCCCC7777  ####---- ,,,, r)r(r)r r*)! __future__rr- collectionsrenumrr threadingr TYPE_CHECKINGtyping_extensionsrr __all__TypeVarr"r#r$Unionr.rr0r1rr&r3GenericMutableMappingr Setrer!rrrrs4"""""" ######  +***** #$4 5fnUfnUfnU  N38 OFLc*+(Z/Z/Z/Z/Z/FN384f6KCQTH6UZ/Z/Z/z-----VZ S#X(>?---`CCCCCV*384CCCCCr