xjU46UdZddlmZddlZddlZddlZddlZddlZddlZddl m Z  ddl Z ejrIejdk\r ddlmZmZn)ddlmZmZej*ej,ZdZd ed <n dZ ddlmZmZd ZGd d ZGddeZGddeZGddeZGddeZGddeZGddeZGddZ GddZ!GddZ"Gd d!Z#eeeeed"Z$d#ed$<e e$jKd%ese$jKd&yy#e $r ddl Z n #e $rdZ YnwxYwY&wxYw#e $r< ddlmZmZej*ej,Zd Zn #e $rYnwxYwYwxYw)'zq Handlers for Content-Encoding. See: https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Encoding ) annotationsN) DecodingError))ZstdDecompressor ZstdErrorFbool_zstandard_installedTceZdZddZddZy)ContentDecoderctNNotImplementedErrorselfdatas d/mnt/ssd/data/Dropbox/adrian/sandbox/mcp-query/venv/lib/python3.12/site-packages/httpx2/_decoders.pydecodezContentDecoder.decode= !##ctrrrs rflushzContentDecoder.flush@rrNrbytesreturnrrr)__name__ __module__ __qualname__rrrrr r <s $$rr c eZdZdZddZddZy)IdentityDecoderz Handle unencoded data. c|Srr#rs rrzIdentityDecoder.decodeIs rcyNrr#rs rrzIdentityDecoder.flushLsrNrr)r r!r"__doc__rrr#rrr%r%Dsrr%c(eZdZdZddZddZddZy) DeflateDecoderzZ Handle 'deflate' decoding. See: https://stackoverflow.com/questions/1838699 cDd|_tj|_y)NT) first_attemptzlib decompressobj decompressorrs r__init__zDeflateDecoder.__init__Ws! ..0rcB|j}d|_ |jj|S#tj$r[}|r?tj tj |_|j|cYd}~Stt||d}~wwxYwNF) r-r0 decompressr.errorr/ MAX_WBITSrrstr)rrwas_first_attemptexcs rrzDeflateDecoder.decode[s .." 3$$//5 5zz 3 $($6$6$G!{{4((C)s 2  3s!0B;B>BBBc |jjS#tj$r}t t ||d}~wwxYwrr0rr.r5rr7rr9s rrzDeflateDecoder.flushfA 3$$**, ,zz 3C)s 2 3A AA NrNonerrr r!r"r)r1rrr#rrr+r+Ps 1 33rr+c(eZdZdZddZddZddZy) GZipDecoderzW Handle 'gzip' decoding. See: https://stackoverflow.com/questions/1838699 cZtjtjdz|_y)N)r.r/r6r0rs rr1zGZipDecoder.__init__ts ..t~~/BCrc |jj|S#tj$r}t t ||d}~wwxYwr)r0r4r.r5rr7rrr9s rrzGZipDecoder.decodewsC 3$$//5 5zz 3C)s 2 3sA AA c |jjS#tj$r}t t ||d}~wwxYwrr;r<s rrzGZipDecoder.flush}r=r>Nr?rrrAr#rrrCrCms D3 3rrCc(eZdZdZddZddZddZy) BrotliDecoderaT Handle 'brotli' decoding. Requires `pip install brotlipy`. See: https://brotlipy.readthedocs.io/ or `pip install brotli`. See https://github.com/google/brotli Supports both 'brotlipy' and 'Brotli' packages since they share an import name. The top branches are for 'brotlipy' and bottom branches for 'Brotli' ct tddtj|_d|_|t |jdr|jj |_y|jj|_y)NzUsing 'BrotliDecoder', but neither of the 'brotlicffi' or 'brotli' packages have been installed. Make sure to install httpx using `pip install httpx[brotli]`.Fr4) brotli ImportError Decompressorr0 seen_datahasattrr4 _decompressprocessrs rr1zBrotliDecoder.__init__sv >P   #//1 4$$l 3#00;;D  $0088D rc|syd|_ |j|S#tj$r}t t ||d}~wwxYwNrT)rOrQrLr5rr7rGs rrzBrotliDecoder.decodesJ 3##D) )|| 3C)s 2 3sA AA c|jsy t|jdr|jjy#tj $r}t t||d}~wwxYw)Nrfinish)rOrPr0rVrLr5rr7r<s rrzBrotliDecoder.flushs]~~ 3t(((3 !!((*|| 3C)s 2 3s0AA-A((A-Nr?rrrAr#rrrJrJs9$3 3rrJc(eZdZdZddZddZddZy) ZStandardDecoderzHandle 'zstd' RFC 8878 decoding. If running on Python 3.14+ or a distro that doesn't have the `compression.zstd` stdlib module, requires either: `pip install zstandard` or `pip install httpx2[zstd]`. cTts tddt|_d|_y)NzXUsing 'ZStandardDecoder', ...Make sure to install httpx using `pip install httpx[zstd]`.F)r rMrr0rOrs rr1zZStandardDecoder.__init__s,#j -.rc|syd|_tj} |jjr(|jj |z}t |_|j|jj||jjr|jj r||jj }t |_|j|jj||jjr|jj r||jS#t$r}tt||d}~wwxYwrT) rOioBytesIOr0eof unused_datarwriter4r rr7getvalue)rroutputr^r9s rrzZStandardDecoder.decodes 3  $$((44t;$4$6! LL**55d; <##''D,=,=,I,I"//;; $4$6! T..99+FG##''D,=,=,I,I    3C)s 2 3sDE E# EE#c`|jsy|jjs tdy)NrzZstandard data is incomplete)rOr0r]rrs rrzZStandardDecoder.flushs*~~  $$ >? ?rNr?rrrAr#rrrXrXs!$rrXc8eZdZUdZdZded<d dZd dZd dZy) MultiDecoderzE Handle the case where multiple encodings have been applied. ztyping.ClassVar[int]max_decode_linksc|Dcgc] }|tvs |}}t||jkDrtd|jdt |Dcgc]}t|c}|_ycc}wcc}w)zk 'encodings' should be the content codings in the order in which each was applied. zCannot apply more than z content encodings.N)SUPPORTED_DECODERSlenrfrreversedchildren)r encodingsencodingcodingscodings rr1zMultiDecoder.__init__s| -6XEW9W8XX w<$// /"9$:O:O9PPc de eZbcjZk.lPV/A&/I/K.l Y/ms A4A4A9cJ|jD]}|j|}|Sr)rkrrrchilds rrzMultiDecoder.decodes(]] &E<<%D & rcpd}|jD]$}|j||jz}&|Sr()rkrrrqs rrzMultiDecoder.flushs8]] 6E<<% 5D 6 rN)rlztyping.Sequence[str]rr@rr) r r!r"r)rf__annotations__r1rrr#rrrdrds%./*. m rrdc*eZdZdZdddZddZd dZy) ByteChunkerz> Handles returning byte content in fixed-size chunks. NcDtj|_||_yr)r[r\_buffer _chunk_sizer chunk_sizes rr1zByteChunker.__init__szz| %rc|j|r|gSgS|jj||jj|jk\r|jj }t dt ||jDcgc]}||||jz}}t |d|jk(r7|jjd|jj|S|jjd|jj|d|jj|ddSgScc}wNr ryrxr_tellr`rangeriseektruncatercontentvalueichunkss rrzByteChunker.decode !    # 'G9 /R / 7# <<   $"2"2 2LL))+E?DQE TXTdTd?ef!eAD$4$4 45fFf6":$"2"22 !!!$ %%'  !!!$ ""6":. %%'cr{"IgEc|jj}|jjd|jj|r|gSgSNrrxr`rrrrs rrzByteChunker.flushE %%' ! w'R'rrr{z int | Nonerr@)rrr list[bytes])rrrAr#rrrvrv&((rrvc*eZdZdZdddZddZd dZy) TextChunkerz> Handles returning text content in fixed-size chunks. NcDtj|_||_yr)r[StringIOrxryrzs rr1zTextChunker.__init__+s{{} %rc|j|r|gSgS|jj||jj|jk\r|jj }t dt ||jDcgc]}||||jz}}t |d|jk(r7|jjd|jj|S|jjd|jj|d|jj|ddSgScc}wr}rrs rrzTextChunker.decode/rrc|jj}|jjd|jj|r|gSgSrrrs rrzTextChunker.flushCrrrr)rr7r list[str]rrrAr#rrrr&rrrc*eZdZdZdddZddZd dZy) TextDecoderz8 Handles incrementally decoding bytes into text cFtj|d|_y)Nreplace)errors)codecsgetincrementaldecoderdecoder)rrms rr1zTextDecoder.__init__Os=v33H=YO rc8|jj|Srrrrs rrzTextDecoder.decodeRs||""4((rc:|jjddSrTrrs rrzTextDecoder.flushUs||""3--rN)zutf-8)rmr7rr@)rrrr7)rr7rAr#rrrrJsP).rrc(eZdZdZddZddZddZy) LineDecoderz Handles incrementally reading lines from text. Has the same behaviour as the stdllib splitlines, but handling the input iteratively. c g|_d|_yr3)buffer trailing_crrs rr1zLineDecoder.__init__as!# !&rcd}|jr d|z}d|_|jdr d|_|dd}|sgS|d|v}|j}t|dk(r"|s |jj |dgS|jr/dj |j|dzg|ddz}g|_|s|jg|_|S) Nu …

 FTr~rr)rendswith splitlinesrirappendjoinpop)rtext NEWLINE_CHARStrailing_newlineliness rrzLineDecoder.decodeesB    $;D$D  == #D 9DI8}4! u:?#3 KK  uQx (I ;;WWT[[)E!H45ab AEDK!99;-DK rc|js|jsgSdj|jg}g|_d|_|S)NrF)rrr)rrs rrzLineDecoder.flushs?{{4#3#3I%&   rNr?)rr7rrrrAr#rrrrYs'$Lrr)identitygzipdeflatebrzstdzdict[str, type[ContentDecoder]]rhrr)&r) __future__rr functoolsr[systypingr. _exceptionsrrLrM brotlicffi TYPE_CHECKING version_infocompression.zstdrr zstandard_ZstdDecompressorpartialr/r rtr r%r+rCrJrXrdrvrrrrhrr#rrrs #  &   7"@@N,9,,->-@-N-NO!&$&  @#$$ n 3^3:3.3.23N23j(~(V>4 6"U  $  8   R0y001B1D1R1RS #'     skD8 E8E>EEE  E E  EEF+F F FFFFF