
    ,h	/                       d Z ddlmZ ddlZddlZddlZddlZddlmZ 	 ddl	Z		 ddlZ G d d      Z G d d	e      Z G d
 de      Z G d de      Z G d de      Z G d de      Z G d de      Z G d d      Z G d d      Z G d d      Z G d d      ZeeeeedZe	ej3                  d       eej3                  d       yy# e
$ r 	 ddlZ	n# e
$ r dZ	Y nw xY wY w xY w# e
$ r dZY w xY w)zq
Handlers for Content-Encoding.

See: https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Encoding
    )annotationsN   )DecodingErrorc                      e Zd ZddZddZy)ContentDecoderc                    t               NNotImplementedErrorselfdatas     Q/var/www/html/Resume-Scraper/venv/lib/python3.12/site-packages/httpx/_decoders.pydecodezContentDecoder.decode%       !##    c                    t               r	   r
   r   s    r   flushzContentDecoder.flush(   r   r   Nr   bytesreturnr   r   r   )__name__
__module____qualname__r   r    r   r   r   r   $   s    $$r   r   c                       e Zd ZdZddZddZy)IdentityDecoderz 
    Handle unencoded data.
    c                    |S r	   r   r   s     r   r   zIdentityDecoder.decode1   s    r   c                     yNr   r   r   s    r   r   zIdentityDecoder.flush4   s    r   Nr   r   )r   r   r   __doc__r   r   r   r   r   r   r   ,   s    r   r   c                  (    e Zd ZdZddZddZddZy)	DeflateDecoderzZ
    Handle 'deflate' decoding.

    See: https://stackoverflow.com/questions/1838699
    c                D    d| _         t        j                         | _        y NT)first_attemptzlibdecompressobjdecompressorr   s    r   __init__zDeflateDecoder.__init__?   s    ! ..0r   c                B   | j                   }d| _         	 | j                  j                  |      S # t        j                  $ r[}|r?t        j
                  t        j                         | _        | j                  |      cY d }~S t        t        |            |d }~ww xY wNF)
r(   r+   
decompressr)   errorr*   	MAX_WBITSr   r   str)r   r   was_first_attemptexcs       r   r   zDeflateDecoder.decodeC   s     .."	3$$//55zz 	3 $($6$6$G!{{4((C)s2		3s!   0 B;B>BBBc                    	 | j                   j                         S # t        j                  $ r}t	        t        |            |d }~ww xY wr	   r+   r   r)   r0   r   r2   r   r4   s     r   r   zDeflateDecoder.flushN   A    	3$$**,,zz 	3C)s2	3    A	AA	Nr   Noner   r   r   r   r   r#   r,   r   r   r   r   r   r%   r%   8   s    1	33r   r%   c                  (    e Zd ZdZddZddZddZy)	GZipDecoderzW
    Handle 'gzip' decoding.

    See: https://stackoverflow.com/questions/1838699
    c                Z    t        j                  t         j                  dz        | _        y )N   )r)   r*   r1   r+   r   s    r   r,   zGZipDecoder.__init__\   s     ..t~~/BCr   c                    	 | j                   j                  |      S # t        j                  $ r}t	        t        |            |d }~ww xY wr	   )r+   r/   r)   r0   r   r2   r   r   r4   s      r   r   zGZipDecoder.decode_   sC    	3$$//55zz 	3C)s2	3s    A
AA
c                    	 | j                   j                         S # t        j                  $ r}t	        t        |            |d }~ww xY wr	   r6   r7   s     r   r   zGZipDecoder.flushe   r8   r9   Nr:   r   r   r<   r   r   r   r>   r>   U   s    D33r   r>   c                  (    e Zd ZdZddZddZddZy)	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'
    c                   t         t        d      d t        j                         | _        d| _        |  t        | j                  d      r| j                  j                  | _        y | j                  j                  | _        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_datahasattrr/   _decompressprocessr   s    r   r,   zBrotliDecoder.__init__v   sv    >P 	 #//14$$l3#00;;D  $0088Dr   c                    |syd| _         	 | j                  |      S # t        j                  $ r}t	        t        |            |d }~ww xY wNr   T)rJ   rL   rG   r0   r   r2   rB   s      r   r   zBrotliDecoder.decode   sJ    	3##D))|| 	3C)s2	3s    A
AA
c                    | j                   sy	 t        | j                  d      r| j                  j                          y# t        j
                  $ r}t        t        |            |d }~ww xY w)Nr   finish)rJ   rK   r+   rQ   rG   r0   r   r2   r7   s     r   r   zBrotliDecoder.flush   s]    ~~
	3t(((3 !!((*|| 	3C)s2	3s   0A   A-A((A-Nr:   r   r   r<   r   r   r   rE   rE   l   s    9$33r   rE   c                  (    e Zd ZdZddZddZddZy)	ZStandardDecoderz
    Handle 'zstd' RFC 8878 decoding.

    Requires `pip install zstandard`.
    Can be installed as a dependency of httpx using `pip install httpx[zstd]`.
    c                    t         t        d      d t        j                         j                         | _        d| _        y )NzXUsing 'ZStandardDecoder', ...Make sure to install httpx using `pip install httpx[zstd]`.F)	zstandardrH   ZstdDecompressorr*   r+   rJ   r   s    r   r,   zZStandardDecoder.__init__   sC    N 
 &668FFHr   c                   t         J d| _        t        j                         }	 |j	                  | j
                  j                  |             | j
                  j                  r| j
                  j                  r| j
                  j                  }t        j                         j                         | _        |j	                  | j
                  j                  |             | j
                  j                  r| j
                  j                  r|j                         S # t         j                  $ r}t        t        |            |d }~ww xY wr'   )rU   rJ   ioBytesIOwriter+   r/   eofunused_datarV   r*   	ZstdErrorr   r2   getvalue)r   r   outputr\   r4   s        r   r   zZStandardDecoder.decode   s    $$	3LL**55d;<##''D,=,=,I,I"//;;$-$>$>$@$N$N$P!T..99+FG ##''D,=,=,I,I    "" 	3C)s2	3s   C)D E2EEc                    | j                   sy| j                  j                         }| j                  j                  st	        d      t        |      S )Nr   zZstandard data is incomplete)rJ   r+   r   r[   r   r   )r   rets     r   r   zZStandardDecoder.flush   sE    ~~%%'  $$ >??Szr   Nr:   r   r   r<   r   r   r   rS   rS      s    !r   rS   c                  (    e Zd ZdZddZddZddZy)	MultiDecoderzE
    Handle the case where multiple encodings have been applied.
    c                6    t        t        |            | _        y)zm
        'children' should be a sequence of decoders in the order in which
        each was applied.
        N)listreversedchildren)r   rg   s     r   r,   zMultiDecoder.__init__   s     Xh/0r   c                J    | j                   D ]  }|j                  |      } |S r	   )rg   r   r   r   childs      r   r   zMultiDecoder.decode   s(    ]] 	&E<<%D	&r   c                p    d}| j                   D ]$  }|j                  |      |j                         z   }& |S r"   )rg   r   r   ri   s      r   r   zMultiDecoder.flush   s8    ]] 	6E<<%5D	6r   N)rg   ztyping.Sequence[ContentDecoder]r   r;   r   r   r<   r   r   r   rc   rc      s    1
r   rc   c                  *    e Zd ZdZdddZddZd	dZy)
ByteChunkerz>
    Handles returning byte content in fixed-size chunks.
    Nc                D    t        j                         | _        || _        y r	   )rX   rY   _buffer_chunk_sizer   
chunk_sizes     r   r,   zByteChunker.__init__   s    zz|%r   c                   | j                   |r|gS g S | j                  j                  |       | j                  j                         | j                   k\  r| j                  j	                         }t        dt        |      | j                         D cg c]  }|||| j                   z     }}t        |d         | j                   k(  r7| j                  j                  d       | j                  j                          |S | j                  j                  d       | j                  j                  |d          | j                  j                          |d d S g S c c}w Nr   	rp   ro   rZ   tellr^   rangelenseektruncater   contentvalueichunkss        r   r   zByteChunker.decode   -   # 'G9/R/7#<<$"2"22LL))+E q#e*d.>.>? a!d.../F  6":$"2"22!!!$%%'!!!$""6":.%%'cr{"I   Ec                    | j                   j                         }| j                   j                  d       | j                   j                          |r|gS g S Nr   ro   r^   rz   r{   r   r~   s     r   r   zByteChunker.flush  E    %%'!w'R'r   r	   rr   z
int | Noner   r;   )r}   r   r   list[bytes])r   r   r<   r   r   r   rm   rm          &.(r   rm   c                  *    e Zd ZdZdddZddZd	dZy)
TextChunkerz>
    Handles returning text content in fixed-size chunks.
    Nc                D    t        j                         | _        || _        y r	   )rX   StringIOro   rp   rq   s     r   r,   zTextChunker.__init__  s    {{}%r   c                   | j                   |r|gS g S | j                  j                  |       | j                  j                         | j                   k\  r| j                  j	                         }t        dt        |      | j                         D cg c]  }|||| j                   z     }}t        |d         | j                   k(  r7| j                  j                  d       | j                  j                          |S | j                  j                  d       | j                  j                  |d          | j                  j                          |d d S g S c c}w rt   rv   r|   s        r   r   zTextChunker.decode  r   r   c                    | j                   j                         }| j                   j                  d       | j                   j                          |r|gS g S r   r   r   s     r   r   zTextChunker.flush+  r   r   r	   r   )r}   r2   r   	list[str]r   r   r<   r   r   r   r   r     r   r   r   c                  *    e Zd ZdZdddZddZd	dZy)
TextDecoderz8
    Handles incrementally decoding bytes into text
    c                F     t        j                  |      d      | _        y )Nreplace)errors)codecsgetincrementaldecoderdecoder)r   encodings     r   r,   zTextDecoder.__init__7  s    =v33H=YOr   c                8    | j                   j                  |      S r	   r   r   r   s     r   r   zTextDecoder.decode:  s    ||""4((r   c                :    | j                   j                  dd      S rO   r   r   s    r   r   zTextDecoder.flush=  s    ||""3--r   N)zutf-8)r   r2   r   r;   )r   r   r   r2   )r   r2   r<   r   r   r   r   r   2  s    P).r   r   c                  (    e Zd ZdZddZddZddZy)	LineDecoderz
    Handles incrementally reading lines from text.

    Has the same behaviour as the stdllib splitlines,
    but handling the input iteratively.
    c                     g | _         d| _        y r.   )buffertrailing_crr   s    r   r,   zLineDecoder.__init__I  s    !#!&r   c                   d}| j                   rd|z   }d| _         |j                  d      rd| _         |d d }|sg S |d   |v }|j                         }t        |      dk(  r"|s | j                  j                  |d          g S | j                  r/dj                  | j                        |d   z   g|dd  z   }g | _        |s|j                         g| _        |S )	Nu   
  FTru   r   r    )r   endswith
splitlinesry   r   appendjoinpop)r   textNEWLINE_CHARStrailing_newlineliness        r   r   zLineDecoder.decodeM  s    B $;D$D==#D9D I8}4!u:?#3KKuQx(I;; WWT[[)E!H45ab	AEDK !99;-DKr   c                    | j                   s| j                  sg S dj                  | j                         g}g | _         d| _        |S )Nr   F)r   r   r   )r   r   s     r   r   zLineDecoder.flushs  s?    {{4#3#3I%& r   Nr:   )r   r2   r   r   r   r<   r   r   r   r   r   A  s    '$Lr   r   )identitygzipdeflatebrzstdr   r   )r#   
__future__r   r   rX   typingr)   _exceptionsr   rG   rH   
brotlicffirU   r   r   r%   r>   rE   rS   rc   rm   r   r   r   SUPPORTED_DECODERSr   r   r   r   <module>r      s9   #  	   &	
$ $	n 	3^ 3:3. 3.23N 23j'~ 'T> 2$( $(N$( $(N. .9 9z  
  
>4 6" i   	$   IsF   C C+ C(CC(C"C(!C""C('C(+C54C5