xL i ddlmZddlZddlZddlZddlZddlZddl Z ddl Z ddl m Z ddlmZmZddlmZmZmZmZddlmZmZmZmZmZmZmZmZddlm Z m!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/m0Z0m1Z1m2Z2m3Z3m4Z4m5Z5m6Z6dd l7m8Z8dd l9m:Z:m;Z;gdZd d!dZ?d d"dZ@d#dZAd$dZB d%dZCGdde jeEeEfZFGddZGGddZHGdde jeEeEfZIy)&) annotationsN)Mapping)Cookie CookieJar) ByteStreamUnattachedStreamencode_requestencode_response)SUPPORTED_DECODERS 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-authorizationcN tj|y#t$rYywxYw)z7 Return `True` if `encoding` is a known codec. FT)codecslookup LookupErrorencodings S/mnt/ssd/data/python-lab/Trading/venv/lib/python3.12/site-packages/httpx/_models.py_is_known_encodingr78s, 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>Cs&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_valuerEJsH% eS !A$u+OPP <<+G ,,r?cltjj}||d<|jdS)N content-type)failobj)emailmessageMessageget_content_charset) content_typemsgs r6_parse_content_type_charsetrOUs4 --   !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 !AceZdZdZ d ddZeddZejddZeddZddZ ddZ dd Z dd Z d d!d Z d"d#d Zd d$d Zd%dZd&dZd'dZd(dZd)dZd*dZd+dZd,dZddZy)-r,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  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)rlrwr5keysror}r=rDs r6rz Headers.keyss>EIZZPPMAsE 4==)4/PUUWWPs'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. )rlrwr5rs r6 multi_itemszHeaders.multi_itemssR"&  3ZZ & T]](C D   sAAc0 ||S#t$r|cYSwxYw)z Return a header value. If multiple occurrences of the header occur then concatenate them together with commas. )KeyError)ror=defaults r6getz 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?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__s++DMM:04zz  +:|^+    .  99U# #sm s+Bc|j|jxsd}|j|jxsd}|j}t|jDcgc]\}\}}}||k(r|} }}}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__0s **T^^6w7LL!:7; ]]_ *34::)>  %%a1:%   M!"-. C 3  "C& I>DJJsO JJ  w I> ? s(Cc8|jj|j}t|jDcgc]\}\}}}|j|k(r| }}}}|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__Hs))+$$T]]3*34::)>  %%a1~~7*   3- K( C 3  s#Bc|jj|j}||jDcgc]\}}}| c}}vScc}}wrk)rcr<r5rl)ror=rr}s r6 __contains__zHeaders.__contains__Zs?YY['' 6 4::>iaac>>>>s A c4t|jSrk)iterrrs r6__iter__zHeaders.__iter__^sDIIK  r?c,t|jSrk)lenrlrs r6__len__zHeaders.__len__as4::r?c t|}|jDcgc] \}}}||f }}}}|jDcgc] \}}}||f }}}}t|t|k(S#t$rYywxYwcc}}}wcc}}}w)NF)r,rXrlsorted)roother other_headersr}r=rD self_list other_lists r6__eq__zHeaders.__eq__ds #ENM8'+||'7'7'GL,A#".!4!4T\\5J5J!K 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)POSTPUTPATCH)sContent-Length0) rercrp setdefaultrShostrYnetlocrr,rv)rodefault_headersr=rD auto_headershas_hosthas_content_lengths r6rzRequest._prepares)//1 0JCyy{116F$,,6V LL # #C /  0 35 T\\)  , S0Ct||0S DHHMM   $((// : ;!dkk5M&M    9 :|dll.>.>>? r?cFt|ds t|jSN_content)hasattrrrrs r6rzRequest.contentstZ( " "}}r?c&t|dszt|jtjsJdj |j|_t|jtst|j |_|j S)6 Read and return the request content. rr?)rr:rtypingIterablerrrrs 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?cr|jjDcic] \}}|dvr||c}}Scc}}w)N)rr__dict__reronamerDs r6 __getstate__zRequest.__getstate__sB $}}224 e33 %K   3cz|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]rrrr) rrrrsrrrrrrrrrr?r6r-r-~s *.&*&*)-#'%)"&:>/38!8!8! ' 8! $ 8!$8!'8!!8!#8! 8!88!-8! 8!t@*  ;  )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& dB dGd)Z' dB dHd*Z(dId+Z) dB dGd,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) ror%rprrr 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._prepare;sP)//1 0JCyy{116F$,,6V LL # #C /  0r?cHt|ds td|jS)ze Returns the time taken for the complete request/response cycle to complete. _elapsedzK'.elapsed' may only be accessed after the response has been read or closed.)r RuntimeErrorr-rs r6elapsedzResponse.elapsedBs, tZ(+ }}r?c||_yrk)r-)ror/s r6r/zResponse.elapsedOs  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.)r&r.rs r6r!zResponse.requestSs* == I }}r?c||_yrk)r&rzs r6r!zResponse.request^s  r?cf |jd}|jddS#t$rYywxYw)N http_versionr9ignoreerrorszHTTP/1.1)rrwr)ror4s r6r4zResponse.http_versionbsB A"&//."AL &&wx&@ @  s $ 00c |jd}|jddS#t$r"tj|j cYSwxYw)N reason_phraser9r5r6)rrwrrget_reason_phraser%)ror9s r6r9zResponse.reason_phraseksV B#'???#CM!'''A A =**4+;+;< < =s$(AAc.|jjS)zA Returns the URL for which the request was made. )r!rSrs r6rSz Response.urlts ||r?cFt|ds t|jSr)rrrrs r6rzResponse.content{stZ(!# #}}r?c&t|dsz|j}|sd|_|jSt|jxsd}dj |j |j|jg|_|jS)N_textrRrur4)rrr>rr5rrwflush)rordecoders r6rz 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. rnrru)rcharset_encodingr7r:r#rArrn)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. r>z?Setting encoding after `text` has been accessed is not allowed.N)rrXrnrzs r6r5zResponse.encodings' 4 !Q r?cT|jjd}|yt|S)zO Return the encoding, as specified by the Content-Type header. z Content-TypeN)rprrO)rorMs r6rBzResponse.charset_encodings, ||''7  *<88r?ct|dsg}|jjdd}|D]@}|jj } t |}|j |Bt|dk(r|d|_ |jSt|dkDrt||_ |jSt|_ |jS#t$rYwxYw)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)rrr)children) rrprrUrcr rYrrrFrr)rodecodersrrD decoder_clss r6_get_content_decoderzResponse._get_content_decoders tZ(-/H\\**+=D*QF  ++-"4U";KOOKM2  8}! (  }} X" ,h ? }}!0 1 }} sC C'&C'c@tj|jS)zU A property which is `True` for 1xx status codes, `False` otherwise. )ris_informationalr%rs r6rLzResponse.is_informationals %%d&6&677r?c@tj|jS)zU A property which is `True` for 2xx status codes, `False` otherwise. )r is_successr%rs r6rNzResponse.is_successs  0 011r?c@tj|jS)a A property which is `True` for 3xx status codes, `False` otherwise. Note that not all responses with a 3xx status code indicate a URL redirect. Use `response.has_redirect_location` to determine responses with a properly formed URL redirection. )r is_redirectr%rs r6rPzResponse.is_redirects  !1!122r?c@tj|jS)zU A property which is `True` for 4xx status codes, `False` otherwise. )ris_client_errorr%rs r6rRzResponse.is_client_error $$T%5%566r?c@tj|jS)zU A property which is `True` for 5xx status codes, `False` otherwise. )ris_server_errorr%rs r6rUzResponse.is_server_errorrSr?c@tj|jS)z] A property which is `True` for 4xx and 5xx status codes, `False` otherwise. )ris_errorr%rs r6rWzResponse.is_errors ~~d..//r?c|jtjtjtjtj tj fvxrd|jvS)zs Returns True for 3xx responses with a properly formed URL redirection, `False` otherwise. Location)r%rMOVED_PERMANENTLYFOUND SEE_OTHERTEMPORARY_REDIRECTPERMANENT_REDIRECTrprs r6has_redirect_locationzResponse.has_redirect_locationsZ   '' ((((   +dll* r?c|j}| td|jr|S|jrd}nd}|jdz}ddddd }|j |d }|j || }t||| ) z> 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)r&r.rNr_r%rformatr)ror!rJ status_class error_typesres r6raise_for_statuszResponse.raise_for_statuss-- ?>  ??K  % %w w  ''3. '"  !__\3HI ..*.=gwFFr?c Btj|jfi|Srk)jsonlibloadsr)rokwargss r6rz Response.json?s}}T\\4V44r?ct|ds*t|_|jj||jS)N_cookies)rr+rpextract_cookiesrs r6rzResponse.cookiesBs1tZ(#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.linksIsc !!&) >I,F3 XXe_ /$ 6   s,Ac|jSrk)r*rs r6num_bytes_downloadedzResponse.num_bytes_downloadedWs)))r?c<d|jd|jdS)Nz )r%r9rs r6rzResponse.__repr__[s%T--.a0B0B/C2FFr?cr|jjDcic] \}}|dvr||c}}Scc}}w)N)rrr(rFr rs r6rzResponse.__getstate__^sB $}}224 eLL %K   rc|jD]\}}t|||d|_i|_t |_y)NT)rerr(rr rrs r6rzResponse.__setstate__es? ;;= 'KD% D$ & '&( r?czt|ds$dj|j|_|jS)7 Read and return the response content. rr?)rr iter_bytesrrs r6rz Response.readls/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. rNrr chunk_sizer!) rrrrangemaxrJr rr&iter_rawrwr?rorir@chunker raw_bytesdecodedchunks r6r~zResponse.iter_bytests" 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)rr5rrr&r~rwr?rorr@r 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)rrr&rrwr?ror@rlines 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)r)rr(rr:rr'r.r*r rr&rrwr?closerorrraw_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. z3Attempted to call an sync close on an async stream.TrN)r:rr'r.r(rr&rrs r6rzResponse.closesg $++~6TU U~~!DN 7 $ !!# $ $ $ $s A44A=cKt|ds+dj|j2cgc3d{}| |jS76ncc}wc}|_"w)r}rr?N)rr aiter_bytesrrs 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) rrrrrrJr rr& aiter_rawrwr?rs 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)rr5rrr&rrwr?rs r6 aiter_textzResponse.aiter_textst}}'?@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)rrr&rrwr?rs 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)rz6Attempted to call an async iterator on an sync stream.TrrrN)r)rr(rr:rrr.r*r rr&rrwr?aclosers r6rzResponse.aiter_raw s  " " " " >>. $++7WX X"&%&"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)rz3Attempted to call an async close on an sync stream.TrN)r:rrr.r(rr&rrs r6rzResponse.aclose)sv $++7TU U~~!DN 7 +kk((*** + ++ + +s0AB B/A>0B4 B >BB B )r%rrprrzResponseContent | Nonerrr rrrrrr!zRequest | NonerzResponseExtensions | Noner"zlist[Response] | Noner#z#str | typing.Callable[[bytes], str]rrr)rdatetime.timedelta)r/rrr)rr-)rDr-rrr)rr(r)rrr)rrrr)rr.)rnrrr)rr+)rz dict[str | None, dict[str, str]]rrrrk)r int | Nonerztyping.Iterator[bytes])rrrtyping.Iterator[str]rr)rr)rrrztyping.AsyncIterator[bytes])rrrtyping.AsyncIterator[str])rr),rrrrsrrr/rr!r4r9rSrrr5rBrJrLrNrPrRrUrWr_rjrrrZrvrrrrr~rrrrrrrrrrrr?r6r.r.s '+*.:>"&04)-@G5'5'$ 5' ( 5'  5'5'5'85' 5'.5''5'>5' 5'n0   ^^   ^^AABB   *__  99288 22  3 377 77 00   ,#GJ5     **G ) .&4 $(, $ $ 4(,$ "*(,$ $8 +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|tr44X>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_headerVs&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)rorrDrrrnrs r6rz Cookies.set]s  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.getwshh -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"  #,SS   A     + 7$&;<N-1"J ?9p:f##CH-p:fB)B)Jq+q+hFf##CH-Fr?