xL i /dZddlmZddlZddlZddlZddlZddlmZ ddl Z ddl Z GddZ Gdd e ZGd d e ZGd d e ZGdde ZGdde ZGdde ZGddZGddZGddZGddZeeeeedZe ej3de ej3dyy#e $r ddl Z n #e $rdZ YnwxYwYwxYw#e $rdZ YwxYw)zq Handlers for Content-Encoding. See: https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Encoding ) annotationsN) DecodingErrorceZdZddZddZy)ContentDecoderctNNotImplementedErrorselfdatas U/mnt/ssd/data/python-lab/Trading/venv/lib/python3.12/site-packages/httpx/_decoders.pydecodezContentDecoder.decode% !##ctr r r s rflushzContentDecoder.flush(rrNrbytesreturnrrr)__name__ __module__ __qualname__rrrrrr$s $$rrc eZdZdZddZddZy)IdentityDecoderz Handle unencoded data. c|Sr rr s rrzIdentityDecoder.decode1s rcyNrrrs rrzIdentityDecoder.flush4srNrr)rrr__doc__rrrrrrr,srrc(eZdZdZddZddZddZy) DeflateDecoderzZ Handle 'deflate' decoding. See: https://stackoverflow.com/questions/1838699 cDd|_tj|_yNT) first_attemptzlib decompressobj decompressorrs r__init__zDeflateDecoder.__init__?s! ..0rcB|j}d|_ |jj|S#tj$r[}|r?tj tj |_|j|cYd}~Stt||d}~wwxYwNF) r(r+ decompressr)errorr* MAX_WBITSrrstr)r rwas_first_attemptexcs rrzDeflateDecoder.decodeCs .." 3$$//5 5zz 3 $($6$6$G!{{4((C)s 2  3s!0B;B>BBBc |jjS#tj$r}t t ||d}~wwxYwr r+rr)r0rr2r r4s rrzDeflateDecoder.flushNA 3$$**, ,zz 3C)s 2 3A AA NrNonerrrrrr#r,rrrrrr%r%8s 1 33rr%c(eZdZdZddZddZddZy) GZipDecoderzW Handle 'gzip' decoding. See: https://stackoverflow.com/questions/1838699 cZtjtjdz|_y)N)r)r*r1r+rs rr,zGZipDecoder.__init__\s ..t~~/BCrc |jj|S#tj$r}t t ||d}~wwxYwr )r+r/r)r0rr2r rr4s rrzGZipDecoder.decode_sC 3$$//5 5zz 3C)s 2 3sA AA c |jjS#tj$r}t t ||d}~wwxYwr r6r7s rrzGZipDecoder.flusher8r9Nr:rrr<rrrr>r>Us D3 3rr>c(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]`.Fr/) brotli ImportError Decompressorr+ seen_datahasattrr/ _decompressprocessrs rr,zBrotliDecoder.__init__vsv >P   #//1 4$$l 3#00;;D  $0088D rc|syd|_ |j|S#tj$r}t t ||d}~wwxYwNrT)rJrLrGr0rr2rBs rrzBrotliDecoder.decodesJ 3##D) )|| 3C)s 2 3sA AA c|jsy t|jdr|jjy#tj $r}t t||d}~wwxYw)Nrfinish)rJrKr+rQrGr0rr2r7s rrzBrotliDecoder.flushs]~~ 3t(((3 !!((*|| 3C)s 2 3s0AA-A((A-Nr:rrr<rrrrErEls9$3 3rrEc(eZdZdZddZddZddZy) ZStandardDecoderz Handle 'zstd' RFC 8878 decoding. Requires `pip install zstandard`. Can be installed as a dependency of httpx using `pip install httpx[zstd]`. ct tddtjj|_d|_y)NzXUsing 'ZStandardDecoder', ...Make sure to install httpx using `pip install httpx[zstd]`.F) zstandardrHZstdDecompressorr*r+rJrs rr,zZStandardDecoder.__init__sC  N  &668FFHrctJd|_tj} |j |j j ||j jr|j jr|j j}tjj|_|j |j j ||j jr|j jr|jS#tj$r}tt||d}~wwxYwr')rUrJioBytesIOwriter+r/eof unused_datarVr* ZstdErrorrr2getvalue)r routputr\r4s rrzZStandardDecoder.decodes$$$ 3 LL**55d; <##''D,=,=,I,I"//;; $-$>$>$@$N$N$P! T..99+FG##''D,=,=,I,I   "" 3C)s 2 3sC)DE 2EE c|jsy|jj}|jjs t dt |S)NrzZstandard data is incomplete)rJr+rr[rr)r rets rrzZStandardDecoder.flushsE~~%%'  $$ >? ?SzrNr:rrr<rrrrSrSs !rrSc(eZdZdZddZddZddZy) MultiDecoderzE Handle the case where multiple encodings have been applied. c6tt||_y)zm 'children' should be a sequence of decoders in the order in which each was applied. N)listreversedchildren)r rgs rr,zMultiDecoder.__init__s Xh/0 rcJ|jD]}|j|}|Sr )rgrr rchilds rrzMultiDecoder.decodes(]] &E<<%D & rcpd}|jD]$}|j||jz}&|Sr")rgrrris rrzMultiDecoder.flushs8]] 6E<<% 5D 6 rN)rgztyping.Sequence[ContentDecoder]rr;rrr<rrrrcrcs1 rrcc*eZdZdZdddZddZd dZy) ByteChunkerz> Handles returning byte content in fixed-size chunks. NcDtj|_||_yr )rXrY_buffer _chunk_sizer chunk_sizes rr,zByteChunker.__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 rprorZtellr^rangelenseektruncater contentvalueichunkss rrzByteChunker.decode-    # 'G9 /R / 7# <<   $"2"2 2LL))+Eq#e*d.>.>?a!d.../F6":$"2"22 !!!$ %%'  !!!$ ""6":. %%'cr{"IEc|jj}|jjd|jj|r|gSgSNrror^rzr{r r~s rrzByteChunker.flushE %%' ! w'R'rr rrz int | Nonerr;)r}rr list[bytes])rrr<rrrrmrm&.(rrmc*eZdZdZdddZddZd dZy) TextChunkerz> Handles returning text content in fixed-size chunks. NcDtj|_||_yr )rXStringIOrorprqs rr,zTextChunker.__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}wrtrvr|s rrzTextChunker.decoderrc|jj}|jjd|jj|r|gSgSrrrs rrzTextChunker.flush+rrr r)r}r2r list[str]rrr<rrrrr rrrc*eZdZdZdddZddZd dZy) TextDecoderz8 Handles incrementally decoding bytes into text cFtj|d|_y)Nreplace)errors)codecsgetincrementaldecoderdecoder)r encodings rr,zTextDecoder.__init__7s=v33H=YO rc8|jj|Sr rrr s rrzTextDecoder.decode:s||""4((rc:|jjddSrOrrs rrzTextDecoder.flush=s||""3--rN)zutf-8)rr2rr;)rrrr2)rr2r<rrrrr2sP).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|_yr.)buffer trailing_crrs rr,zLineDecoder.__init__Is!# !&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 …

 FTrurr)rendswith splitlinesryrappendjoinpop)r text NEWLINE_CHARStrailing_newlineliness rrzLineDecoder.decodeMsB    $;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)r rs rrzLineDecoder.flushss?{{4#3#3I%&   rNr:)rr2rrrr<rrrrrAs'$Lrr)identitygzipdeflatebrzstdrr)r# __future__rrrXtypingr) _exceptionsrrGrH brotlicffirUrrr%r>rErSrcrmrrrSUPPORTED_DECODERSrrrrrs9 # &  $$ n 3^3:3.3.23N23j'~'T>2$($(N$($(N . .99z     >4  6"i  $  IsFC C+ C(CC(C"C(!C""C('C(+C54C5