xj,ddlmZddlZddlZddlZddlZddlZddl Z ddl Z ddl m Z ddlmZmZddlmZmZmZmZddlmZmZmZmZmZmZmZddlmZm Z m!Z!m"Z"m#Z#m$Z$m%Z%dd l&m'Z'dd l(m)Z)dd l*m+Z+m,Z,m-Z-m.Z.m/Z/m0Z0m1Z1m2Z2m3Z3m4Z4m5Z5dd l6m7Z7dd l8m9Z9m:Z:gdZ;ddhZ<e jzdZ>d dZ?d!d"dZ@d!d#dZAd$dZBd%dZC d&dZDGdde jeFeFfZGGddZHGddZIGdde jeFeFfZJy)') annotationsN)Mapping)Cookie CookieJar) ByteStreamUnattachedStreamencode_requestencode_response) ByteChunkerContentDecoderIdentityDecoder LineDecoder MultiDecoder TextChunker TextDecoder)CookieConflictHTTPStatusErrorRequestNotReadResponseNotRead StreamClosedStreamConsumedrequest_context)(get_multipart_boundary_from_content_type)codes) AsyncByteStream CookieTypes HeaderTypesQueryParamTypesRequestContent RequestDataRequestExtensions RequestFilesResponseContentResponseExtensionsSyncByteStream)URL)to_bytes_or_strto_str)CookiesHeadersRequestResponse authorizationzproxy-authorization_TcN tj|y#t$rYywxYw)z7 Return `True` if `encoding` is a known codec. FT)codecslookup LookupErrorencodings b/mnt/ssd/data/Dropbox/adrian/sandbox/mcp-query/venv/lib/python3.12/site-packages/httpx2/_models.py_is_known_encodingr79s, h  s  $$cPt|tr|S|j|xsdS)zE Coerce str/bytes into a strictly byte-wise HTTP header key. ascii) isinstancebytesencode)keyr5s r6_normalize_header_keyr>Ds&S%(3Mcjj9LW.MMct|tr|St|tstdt ||j |xsdS)zG Coerce str/bytes into a strictly byte-wise HTTP header value. z'Header value must be str or bytes, not r9)r:r;str TypeErrortyper<)valuer5s r6_normalize_header_valuerEKsH% eS !A$u+OPP <<+G ,,r?cltjj}||d<|jdS)N content-type)failobj)emailmessageMessageget_content_charset) content_typemsgs r6_parse_content_type_charsetrOVs4 --   !C&C  " "4 " 00r?cg}d}|j|}|s|Stjd|D]} |jdd\}}d|jdi}|jdD]:} |jd\}}|j|||j|<<|j ||S#t$r|d}}YwxYw#t$rY4wxYw) a7 Returns a list of parsed link headers, for more info see: https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Link The generic syntax of those is: Link: < uri-reference >; param1=value1; param2="value2" So for instance: Link; '; type="image/jpeg",;' would return [ {"url": "http:/.../front.jpeg", "type": "image/jpeg"}, {"url": "http://.../back.jpeg"}, ] :param value: HTTP Link entity-header field :return: list of parsed link headers z '"z, *<;rurlz<> '"=)stripresplit ValueErrorappend) rDlinks replace_charsvalrSparamslinkparamr=s r6_parse_header_linksr`^s #%EM KK &E  xx&  "))C+KCsyy*+\\#& HE "[[- U.3[[-GD=) *  H  T  L "rC "   s#B?1C? CC CCc#K|D]7\}}t|jtvr td|}||f9yw)Nz[secure]) match_type_of)r)lowerSENSITIVE_HEADERSr()itemskvs r6_obfuscate_sensitive_headersrhsD1 !'')  1 1 !Ac\eZdZdZ d ddZeddZejddZed dZd!dZ d"dZ d#d Z d$d Z e jd%d Ze jd&d Zd'd(d Zd)d*dZd'd+dZd,dZd-dZd-dZd.dZd/dZd0dZd1dZd2dZd3dZd4dZd5dZddZy)6r+z9 HTTP headers, as a case-insensitive multi-dict. Nc g|_t|tr"t|j|_||_ yt|trd|j D]I\}}t ||}t||}|jj||j|fK||_ y|N|D]I\}}t ||}t||}|jj||j|fK||_ yN) _listr:r+listrrer>rErYrc _encoding)selfheadersr5rfrg bytes_key bytes_values r6__init__zHeaders.__init__s 8: gw 'gmm,DJ" )  O11!X> 5aB  !!9ioo.?"MN O"   O11!X> 5aB  !!9ioo.?"MN O "r?c|jXdD]L}|jD](\}} |j||j|*||_|jSd|_|jS#t$rYnwxYw)zn Header encoding is mandated as ascii, but we allow fallbacks to utf-8 or iso-8859-1. )r9utf-8z iso-8859-1)rnrawdecodeUnicodeDecodeError)ror5r=rDs r6r5zHeaders.encodings >> !. ."&(( JC 8, X. &.DN ~~! .".~~.s"A11 A>=A>c||_yrk)rnrorDs r6r5zHeaders.encodings r?cX|jDcgc] \}}}||f c}}}Scc}}}w)zH Returns a list of the raw header items, as byte pairs. )rl)roraw_key_rDs r6rvz Headers.raws+ ;?**EE%6Wa% EEEs%c|jDcic]"\}}}|j|jd$c}}}jScc}}}wrk)rlrwr5keys)ror}r=_values r6rz Headers.keyss>FJjjQQNAsF 4==)4/QVVXXQs'A ci}|jD]V\}}}|j|j}|j|j}||vr||xxd|z cc<R|||<X|jS)N, )rlrwr5valuesro values_dictr}r=rDstr_key str_values r6rzHeaders.valuess~&( !ZZ 1MAsEjj/G T]]3I+%G$"YK(88$'0 G$  1!!##r?ci}|jD]V\}}}|j|j}|j|j}||vr||xxd|z cc<R|||<X|jS)z Return `(key, value)` items of headers. Concatenate headers into a single comma separated value when a key occurs multiple times. r)rlrwr5rers r6rez Headers.itemss ') !ZZ 1MAsEjj/G T]]3I+%G$"YK(88$'0 G$  1  ""r?c |jDcgc]<\}}}|j|j|j|jf>c}}}Scc}}}w)z Return a list of `(key, value)` pairs of headers. Allow multiple occurrences of the same key without concatenating into a single comma separated value. )rlrwr5)ror}r=rDs r6 multi_itemszHeaders.multi_itemssJ _c^h^hii]QPSUZDMM*ELL,GHiiisAAcyrk)ror=s r6getz Headers.gets.1r?cyrkrror=defaults r6rz Headers.gets69r?c0 ||S#t$r|cYSwxYw)z Return a header value. If multiple occurrences of the header occur then concatenate them together with commas. )KeyErrorrs r6rz Headers.gets%  9  N s  c|jj|j}|jDcgc]4\}}}|j|k(r|j |j6}}}}|s|Sg}|D]>} |j | j dD cgc]} | jc} @|Scc}}}wcc} w)z Return a list of all header values for a given key. If `split_commas=True` is passed, then any comma separated header values are split into multiple return strings. ,)rcr<r5rlrwextendrWrU) ror= split_commasget_header_keyr}item_key item_valuer split_valuesrDitems r6get_listzHeaders.get_lists ++DMM:,0::  '8Z~~>1   dmm ,  M"$  ME   %++c:J K$ K L M !Ls 9C C ct|}|jD]}||vs|j||jj |jyrk)r+rpoprlr)rorpr=s r6updatezHeaders.updatesK'"<<> Cd{   '--(r?c0t||jS)Nr4)r+r5ros r6copyz Headers.copystdmm44r?ctt|tstS|j}|j ||Srk)r:rNotImplementedrrroothermergeds r6__or__zHeaders.__or__ s.%)! ! e r?cjt|tstSt|}|j ||Srk)r:rrr+rrs r6__ror__zHeaders.__ror__'s,%)! ! d r?c(|j||Srk)r)rors r6__ior__zHeaders.__ior__.s E r?c|jj|j}|jDcgc]&\}}}||k(r|j |j(}}}}|rdj |St |cc}}}w)z Return a single header value. If there are multiple headers with the same key, then we concatenate them with commas. See: https://tools.ietf.org/html/rfc7230#section-3.2.2 r)rcr<r5rlrwjoinr)ror=normalized_keyr} header_key header_valueres r6 __getitem__zHeaders.__getitem__2s++DMM:04zz  +:|^+    .  99U# #sm s+Bc|j|jxsd}|j|jxsd}|j}t|jDcgc]\}\}}}||k(s|} }}}t | ddD]}|j|=| r| d}|||f|j|<y|jj |||fycc}}}w)zs Set the header `key` to `value`, removing any duplicate entries. Retains insertion order. rurNr)r<rnrc enumeraterlreversedrY) ror=rDset_key set_value lookup_keyidxr}r found_indexess r6 __setitem__zHeaders.__setitem__Fs **T^^6w7LL!:7; ]]_ :CDJJ:Ojj!6&6q(AS[_iSij jM!"-. C 3  "C& I>DJJsO JJ  w I> ?ks (C:Cc:|jj|j}t|jDcgc]\}\}}}|j|k(s|!}}}}|s t |t |D]}|j|=ycc}}}w)z* Remove the header `key`. N)rcr<r5rrlrr)ror=del_keyrr}r pop_indexess r6 __delitem__zHeaders.__delitem__Zs))+$$T]]38A$**8Mmm4s$4Q!QYQ_Q_QaelQlsm m3- K( C 3 ns B#Bc|jj|j}||jDcgc]\}}}| c}}vScc}}wrk)rcr<r5rl)ror=rr}s r6 __contains__zHeaders.__contains__hs?YY['' 6 4::>iaac>>>>s A c4t|jSrk)iterrrs r6__iter__zHeaders.__iter__lsDIIK  r?c,t|jSrk)lenrlrs r6__len__zHeaders.__len__os4::r?c t|}|jDcgc] \}}}||f }}}}|jDcgc] \}}}||f }}}}t|t|k(S#t$rYywxYwcc}}}wcc}}}w)NF)r+rXrlsorted)ror other_headersr}r=rD self_list other_lists r6__eq__zHeaders.__eq__rs #ENM8'+||'7'7'GL,AO[!4!4T\\5J5J!Kae OGV MM' " DK&*- ."!DKr?c|jD]C\}}|jdk(rd|jvr(|jj||Eg}d|jv}d|jvxsd|jv}|s=|jj r'|j d|jjf|s|jdvr|j dt||jjz|_y)Ntransfer-encodingzContent-LengthHostzTransfer-EncodingsHost)POSTPUTPATCHQUERY)sContent-Length0) rercrp setdefaultrShostrYnetlocrr+rv)rodefault_headersr=rD auto_headershas_hosthas_content_lengths r6rzRequest._prepares)//1 0JCyy{116F$,,6V LL # #C /  0 35 T\\)-=dATX\XdXdAdDHHMM   $((// : ;!dkk5V&V    9 :|dll.>.>>? r?cFt|ds t|jSN_content)hasattrrr rs r6rzRequest.contentstZ( " "}}r?c&t|dszt|jtjsJdj |j|_t|jtst|j |_|j S)6 Read and return the request content. r r?)r r:rrIterablerr rrs r6rz Request.readsdtZ(dkk6??; ;;HHT[[1DMdkk:6)7 }}r?cjKt|dsMt|jtjsJdj |j2cgc3d{}| |j S76ncc}wc}|_t|jtr)rrrArSr)rorrSs r6rzRequest.__repr__s=^^,, $((m:,a br::r?ct|jjDcic] \}}|dvs ||c}}Scc}}w)N)rr__dict__reronamerDs r6 __getstate__zRequest.__getstate__s3/3}}/B/B/Dm eTlHle mmms 44cz|jD]\}}t|||i|_t|_yrk)resetattrrr rrostaterrDs r6 __setstate__zRequest.__setstate__s8 ;;= 'KD% D$ & '&( r?)rrArSz URL | strr]zQueryParamTypes | NonerprrCookieTypes | NonerzRequestContent | NonerzRequestData | NonerzRequestFiles | Nonerztyping.Any | Noner'SyncByteStream | AsyncByteStream | NonerzRequestExtensions | Nonerrrzdict[str, str]rrrr;rrdict[str, typing.Any]r!r(rr) rrrrsrrrrrrrr"rr?r6r,r,s *.&*&*)-#'%)"&:>/36!6!6! ' 6! $ 6!$6!'6!!6!#6! 6!86!-6! 6!p@&  ; n)r?r,c eZdZddddddddddd d.dZd/dZed0dZejd1dZed2dZejd3d Zed4d Z ed4d Z ed5d Z ed6d Z ed4dZ ed7dZejd8dZed7dZd9dZed:dZed:dZed:dZed:dZed:dZed:dZed:dZd;dZddZed?dZd4dZd@d ZdAd!Zd6d"Z dBdCd#Z!dBdDd$Z"dEd%Z#dBdCd&Z$dFd'Z%d6d(Z&dBdGd)Z'dBdHd*Z(dId+Z)dBdGd,Z*dFd-Z+y)Jr-Nru) rprtexthtmlrrrequestrhistorydefault_encodingc ||_t||_||_d|_| in t | |_| gn t| |_d|_ d|_ | |_ |Qt||||\}}|j|||_t|t r|j#d|_y||_d|_y)NFr) status_coder+rp_request next_requestrrrmr. is_closedis_stream_consumedr/r rrr:rr_num_bytes_downloaded) ror1rprr+r,rrr-rr.r/s r6rszResponse.__init__ s'w' (/ -1 * 2"Z8H$_r$w- "' 0 >-gtT4HOGV MM' " DK&*- &'"!DK%&"r?c|jD]C\}}|jdk(rd|jvr(|jj||Ey)Nrzcontent-length)rercrpr)rorr=rDs r6rzResponse._prepareAsP)//1 0JCyy{116F$,,6V LL # #C /  0r?c~t|ds&t|jdd}||Std|jS)ze Returns the time taken for the complete request/response cycle to complete. _elapsedelapsedNzK'.elapsed' may only be accessed after the response has been read or closed.)r getattrr RuntimeErrorr9)rostream_elapseds r6r:zResponse.elapsedHsC tZ(8? YX\8]N)%%lm m}}r?c||_yrk)r9)ror:s r6r:zResponse.elapsedUs  r?cH|j td|jS)zR Returns the request instance associated to the current response. z7The request instance has not been set on this response.)r2r<rs r6r-zResponse.requestYs$ == XY Y}}r?c||_yrk)r2rzs r6r-zResponse.requestbs  r?cf |jd}|jddS#t$rYywxYw)N http_versionr9ignoreerrorszHTTP/1.1)rrwr)rorBs r6rBzResponse.http_versionfsB A"&//."AL &&wx&@ @  s $ 00c |jd}|jddS#t$r"tj|j cYSwxYw)N reason_phraser9rCrD)rrwrrget_reason_phraser1)rorGs r6rGzResponse.reason_phraseosV B#'???#CM!'''A A =**4+;+;< < =s$(AAc.|jjS)zA Returns the URL for which the request was made. )r-rSrs r6rSz Response.urlxs ||r?cFt|ds t|jSr )r rr rs r6rzResponse.contentstZ(!# #}}r?c&t|dsz|j}|sd|_|jSt|jxsd}dj |j |j|jg|_|jS)N_textrRrur4)r rrLrr5rrwflush)rordecoders r6r+z Response.textsrtW%llG zz&t}}/GHWWgnnT\\&BGMMO%TU zzr?ct|dsr|j}| t|sNt|jt r |j}n't|dr|j |j }|xsd|_|jS)a Return an encoding to use for decoding the byte content into text. The priority for determining this is given by... * `.encoding = <>` has been set explicitly. * The encoding as specified by the charset parameter in the Content-Type header. * The encoding as determined by `default_encoding`, which may either be a string like "utf-8" indicating the encoding to use, or may be a callable which enables charset autodetection. rnr ru)r charset_encodingr7r:r/rAr rn)ror5s r6r5zResponse.encodingsvt[),,H'9('Cd33S9#44HT:.#44T]]CH%0DN~~r?c@t|dr td||_y)z Set the encoding to use for decoding the byte content into text. If the `text` attribute has been accessed, attempting to set the encoding will throw a ValueError. rLz?Setting encoding after `text` has been accessed is not allowed.N)r rXrnrzs r6r5zResponse.encodings! 4 !^_ _r?cT|jjd}|yt|S)zO Return the encoding, as specified by the Content-Type header. z Content-TypeN)rprrO)rorMs r6rPzResponse.charset_encodings, ||''7  *<88r?ct|ds|jjdd}|Dcgc] }|jj "}}t |Dcgc] }|dk7s | c}}t |jdk(r |jd|_|jS|jr||_|jSt|_|jScc}wcc}w)z Returns a decoder instance which can be used to decode the raw byte content, depending on the Content-Encoding used in the response. _decoderzcontent-encodingT)ridentityrr) r rprrUrcrrchildrenrTr)rorrD encodingsr5rNs r6_get_content_decoderzResponse._get_content_decoders tZ(\\**+=D*QF Raise the `HTTPStatusError` if one occurred. zYCannot call `raise_for_status` as the request instance has not been set on this response.z{error_type} '{0.status_code} {0.reason_phrase}' for url '{0.url}' Redirect location: '{0.headers[location]}' For more information check: https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/{0.status_code}z{error_type} '{0.status_code} {0.reason_phrase}' for url '{0.url}' For more information check: https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/{0.status_code}dzInformational responsezRedirect responsez Client errorz Server error)rzInvalid status code) error_type)r-response)r2r<r\rmr1rformatr)ror-rJ status_class error_typesrss r6raise_for_statuszResponse.raise_for_statuss-- ?k  ??K  % %w w  ''3. '"  !__\3HI ..*.=gwFFr?c Btj|jfi|Srk)jsonlibloadsr)rokwargss r6rz Response.json9s}}T\\4V44r?ct|ds*t|_|jj||jS)N_cookies)r r*r~extract_cookiesrs r6rzResponse.cookies<s1tZ(#IDM MM ) )$ /}}r?c|jjd}|iSt|Dcic]'}|jdxs|jd|)c}Scc}w)zI Returns the parsed header links of the response, if any r^relrS)rprr`)roheaderr^s r6rZzResponse.linksCsV !!&) >IGZ[aGbct%3DHHUOd:cccs,Ac|jSrk)r6rs r6num_bytes_downloadedzResponse.num_bytes_downloadedNs)))r?c<d|jd|jdS)Nz )r1rGrs r6rzResponse.__repr__Rs%T--.a0B0B/C2FFr?cr|jjDcic] \}}|dvr||c}}Scc}}w)N)rrr4rTrrs r6rzResponse.__getstate__UsB $}}224 eLL %K   s3c|jD]\}}t|||d|_i|_t |_y)NT)rerr4rr rr s r6r"zResponse.__setstate__\s? ;;= 'KD% D$ & '&( r?czt|ds$dj|j|_|jS)7 Read and return the response content. r r?)r r iter_bytesr rs r6rz Response.readcs/tZ(HHT__%67DM}}r?c#tKt|dr]|t|jn|}tdt|jt |dD]}|j|||zy|j }t |}t|j5|jD]-}|j|}|j|D]}|/|j}|j|D]}||jD]}| dddy#1swYyxYwwz A byte-iterator over the decoded response content. This allows us to handle gzip, deflate, brotli, and zstd encoded responses. r Nrr chunk_sizer-) r rr rangemaxrXr rr2iter_rawrwrMrorirNchunker raw_bytesdecodedchunks r6rzResponse.iter_bytesks" 4 $/9/AT]]+zJ1c$--0#j!2DE 8mmAJ77 8//1G!Z8G 7 !%$I%nnY7G!(!8$# $$"--/$^^G4 EK $]]_ EK  sBD8BD,# D8,D51D8c#Kt|jxsd}t|}t|j5|j D]-}|j |}|j |D]}|/|j}|j |D]}||jD]}| dddy#1swYyxYwwz A str-iterator over the decoded response content that handles both gzip, deflate, etc but also detects the content's string encoding. rur4rrN)rr5rrr2rrwrMrorrNr byte_content text_contentrs r6 iter_textzResponse.iter_texts t}}'?@4 T]] 3  $ 1 &~~l; $^^L9 EK  #==?L  5          s=CBC  C CCc#Kt}t|j5|jD]}|j |D]}||j D]}| dddy#1swYyxYwwNr)rrr2rrwrMrorNr+lines r6 iter_lineszResponse.iter_liness|- T]] 3 ( #NN40DJ         s!BA A6- B6A?;Bc#K|jr t|jr tt |j t s tdd|_d|_t|}t|j5|j D]:}|xjt|z c_|j|D]}|< ddd|jD]}||jy#1swY3xYww)@ A byte-iterator over the raw response content. z5Attempted to call a sync iterator on an async stream.TrrrN)r5rr4rr:rr&r<r6r rr2rrwrMcloserorrraw_stream_bytesrs r6rzResponse.iter_raws  " " " " >>. $++~6VW W"&%&"4 T]] 3 $(KK  **c2B.CC*$^^,<= EK   ]]_ EK    sBD A D2D D D ct|jts td|jsAd|_t |j 5|jjdddyy#1swYyxYw) Close the response and release the connection. Automatically called if the response body is read to completion. z2Attempted to call a sync close on an async stream.TrN)r:rr&r<r4rr2rrs r6rzResponse.closesg $++~6ST T~~!DN 7 $ !!# $ $ $ $s A44A=cKt|ds+dj|j2cgc3d{}| |jS76ncc}wc}|_"w)rr r?N)r r aiter_bytesr rs r6rzResponse.areadsMtZ(HHT=M=M=O%P%PTd}}&Q%P%PQDMs5*AA A AA A  AA A  AcKt|dr^|t|jn|}tdt|jt |dD]}|j|||zy|j }t |}t|j5|j23d{}|j|}|j|D]}| 6716|j}|j|D]}| |jD]}|  dddy#1swYyxYwwr) r rr rrrXr rr2 aiter_rawrwrMrs r6rzResponse.aiter_bytess, 4 $/9/AT]]+zJ1c$--0#j!2DE 8mmAJ77 8//1G!Z8G 7 '+~~'7$$)%nnY7G!(!8$# $$'7"--/$^^G4 EK $]]_ EK  sCBED80C(4C&5C(8.D8&C((AD8/ E8E=EcKt|jxsd}t|}t|j5|j 23d{}|j |}|j |D]}| 6716|j}|j |D]}| |jD]}|  dddy#1swYyxYwwr)rr5rrr2rrwrMrs r6 aiter_textzResponse.aiter_texts t}}'?@4 T]] 3 &*&6&6&8  l&~~l; $^^L9 EK  &8#==?L  5          sA=C$CBBB.CBAC C$C!C$cKt}t|j5|j23d{}|j |D]}| %7 6|j D]}|  dddy#1swYyxYwwr)rrr2rrwrMrs r6 aiter_lineszResponse.aiter_liness- T]] 3 "oo/  d#NN40DJ /        s<!B BAAABAB7 B B B cFK|jr t|jr tt |j t s tdd|_d|_t|}t|j5|j 23d{}|xjt|z c_|j|D]}| C7>6 dddn #1swYnxYw|jD]}| |jd{7yw)rz5Attempted to call an async iterator on a sync stream.TrrrN)r5rr4rr:rrr<r6r rr2rrwrMaclosers r6rzResponse.aiter_raws  " " " " >>. $++7VW W"&%&"4 T]] 3 *.++  &**c2B.CC*$^^,<= EK  +   ]]_ EK kkmsNBD! C!CCC;C!CC! D!!C*&4D!DD!cKt|jts td|jsId|_t |j 5|jjd{dddyy7#1swYyxYww)rz2Attempted to call an async close on a sync stream.TrN)r:rrr<r4rr2rrs r6rzResponse.aclosesv $++7ST T~~!DN 7 +kk((*** + ++ + +s0AB B/A>0B4 B >BB B )r1rrprrzResponseContent | Noner+rr,rrrrr$r-zRequest | NonerzResponseExtensions | Noner.zlist[Response] | Noner/z*str | typing.Callable[[bytes], str | None]rrr%)rdatetime.timedelta)r:rrr)rr,)rDr,rrr)rr'r&)rrr)rr rr)rr-)r|rrr)rr*)rz dict[str | None, dict[str, str]]rr'r)rk)r int | Nonerztyping.Iterator[bytes])rrrtyping.Iterator[str]rr)rr)rrrztyping.AsyncIterator[bytes])rrrtyping.AsyncIterator[str])rr),rrrrsrrr:rr-rBrGrSrr+r5rPrXrZr\r^r`rcrermrxrrrZrrrr"rrrrrrrrrrrrrr?r6r-r- s '+*.:>"&04)-GN5'5'$ 5' ( 5'  5'5'5'85' 5'.5''5'E5' 5'n0   ^^   ^^AABB   *__  99$88 22  3 377 77 00   ,"GH5 dd**G ) .&4 $ .&4 +r?r-ceZdZdZdddZddZddZdddZ d ddZ d ddZ dd d Z ddd Z d!d Z d"d Z d#d Zd$dZd%dZd&dZd'dZGddej(j*ZGddZy)(r*z- HTTP Cookies, as a mutable mapping. Nc|t|trKt|_t|tr+|j D]\}}|j ||yyt|t r,t|_|D]\}}|j ||yt|trs\ x// /MIYIY4Y 44X>2283C3CD   .Ar?c\|j|}|jj|y)zM Sets an appropriate 'Cookie:' HTTP header on the `Request`. N)rradd_cookie_header)ror-rs r6rzCookies.set_cookie_headerJs&227; "">2r?ciddd|d|ddddd |d t|d |jd d |dt|dddddddddddddidd}tdi|}|jj |y)zU Set a cookie value by name. May optionally include domain and path. versionrrrDportNport_specifiedFdomaindomain_specifieddomain_initial_dot.pathpath_specifiedsecureexpiresdiscardTcomment comment_urlrestHttpOnlyrfc2109r)r startswithrrr)rorrDrrr|rs r6rz Cookies.setQs  q D  U  D  e  f   V   !&"3"3C"8  D  d4j  e  t  t  t  4 Z&! " u# &!&! F#r?cd}|jD]T}|j|k(s||j|k(s%||j|k(s7|d|}t ||j }V||S|S)z Get a cookie by name. May optionally include domain and path in order to specify exactly which cookie to retrieve. Nz!Multiple cookies exist with name=)rrrrrrD)rorrrrrDrrJs r6rz Cookies.getkshh -F{{d">V]]f%<|v{{d': ,(I$&PG"0"99 &  - =N r?ch|||jj|||S|jDcgc]5}|j|k(r$||j|k(r||j|k(r|7}}|D]=}|jj|j|j|j?ycc}w)z Delete a cookie by name. May optionally include domain and path in order to specify exactly which cookie to delete. N)rclearrrr)rorrrrremoves r6deletezCookies.deletes  $"288>>&$5 5(( {{d"6==F#:!4    DF HHNN6==&++v{{ C D s:B/cg}||j|||J|j||jj|y)z Delete all cookies. Optionally include a domain and path in order to only delete a subset of all the cookies. N)rYrr)rorrargss r6rz Cookies.clearsK    KK   % %% KK r?crt|}|jD]}|jj|yrk)r*rr)rorrs r6rzCookies.updates1'"kk (F HH   ' (r?c&|j||Srk)rrs r6rzCookies.__setitem__sxxe$$r?cB|j|}| t||Srk)rrrs r6rzCookies.__getitem__s# =4.  r?c$|j|Srk)r)rors r6rzCookies.__delitem__s{{4  r?c,t|jSrk)rrrs r6rzCookies.__len__s488}r?c(d|jDS)Nc34K|]}|jywrk)r).0rs r6 z#Cookies.__iter__..s3 3srrs r6rzCookies.__iter__s3$((33r?c(|jD]}yy)NTFr)ror}s r6__bool__zCookies.__bool__s A r?c dj|jDcgc],}d|jd|jd|jd.c}}d|dScc}w)Nrzz rErOr`rhMutableMappingrAr+r,r-r*rr?r6rs"  #,SSA     + 7$&;<V^^DN-1"J ?9}:f##CH-}:@z)z)z\+\+~Ff##CH-Fr?