
    Wh                     8   d dl Z d dlZd dlmZ d dlmZmZmZm	Z	m
Z
mZmZmZ d dlmZ ddlmZmZ ddlmZ ddlmZmZ dd	lmZmZmZmZ dd
lmZmZ  G d dee          Z  G d de          Z! G d de          Z" G d dee          Z#dee$e%e
e%         ee%         f         dee	e$e$f         eeef         f         fdZ&de'dee	e$e$f         e f         fdZ(	 d#de'dede%dee	e$e$f         ef         fdZ)de$dee	e$e$f         e f         fdZ*de$dee	e$e$f         e f         fdZ+dedee	e$e$f         e f         fd Z,	 	 	 	 	 d$dedededede%dee	e$e$f         eeef         f         fd!Z-	 	 	 	 d%dede$de$dedee	e$e$f         eeef         f         f
d"Z.dS )&    N)dumps)AnyAsyncIterableAsyncIteratorDictIterableIteratorTupleUnion)	urlencode   )StreamClosedStreamConsumed)MultipartStream)AsyncByteStreamSyncByteStream)RequestContentRequestDataRequestFilesResponseContent)peek_filelike_lengthprimitive_value_to_strc                   N    e Zd ZdeddfdZdee         fdZdee         fdZdS )
ByteStreamstreamreturnNc                     || _         d S N_streamselfr   s     T/var/www/html/movieo_spanner_bot/venv/lib/python3.11/site-packages/httpx/_content.py__init__zByteStream.__init__   s        c              #      K   | j         V  d S r   r   r"   s    r#   __iter__zByteStream.__iter__   s      lr%   c                   K   | j         W V  d S r   r   r'   s    r#   	__aiter__zByteStream.__aiter__   s      lr%   )	__name__
__module____qualname__bytesr$   r	   r(   r   r*    r%   r#   r   r      su        u     (5/    u!5      r%   r   c                   >    e Zd Zdee         fdZdee         fdZdS )IteratorByteStreamr   c                 T    || _         d| _        t          j        |          | _        d S NF)r    _is_stream_consumedinspectisgenerator_is_generatorr!   s     r#   r$   zIteratorByteStream.__init__#   s*    #( $088r%   r   c              #   l   K   | j         r| j        rt                      d| _         | j        D ]}|V  d S NTr4   r7   r   r    r"   parts     r#   r(   zIteratorByteStream.__iter__(   sU      # 	#(: 	# """#' L 	 	DJJJJ	 	r%   N)r+   r,   r-   r   r.   r$   r	   r(   r/   r%   r#   r1   r1   "   sR        9x 9 9 9 9
(5/      r%   r1   c                   >    e Zd Zdee         fdZdee         fdZdS )AsyncIteratorByteStreamr   c                 T    || _         d| _        t          j        |          | _        d S r3   )r    r4   r5   
isasyncgenr7   r!   s     r#   r$   z AsyncIteratorByteStream.__init__2   s*    #( $/77r%   r   c                z   K   | j         r| j        rt                      d| _         | j        2 3 d {V }|W V  6 d S r9   r:   r;   s     r#   r*   z!AsyncIteratorByteStream.__aiter__7   so      # 	#(: 	# """#' , 	 	 	 	 	 	 	$JJJJJ ',,s   :N)r+   r,   r-   r   r.   r$   r   r*   r/   r%   r#   r>   r>   1   sT        8}U3 8 8 8 8
u!5      r%   r>   c                   B    e Zd ZdZdee         fdZdee         fdZdS )UnattachedStreamz
    If a request or response is serialized using pickle, then it is no longer
    attached to a stream for I/O purposes. Any stream operations should result
    in `httpx.StreamClosed`.
    r   c                     t                      r   r   r'   s    r#   r(   zUnattachedStream.__iter__G   s    nnr%   c                "   K   t                      r   rE   r'   s    r#   r*   zUnattachedStream.__aiter__J   s      nnr%   N)	r+   r,   r-   __doc__r	   r.   r(   r   r*   r/   r%   r#   rC   rC   @   s]         (5/    u!5      r%   rC   contentr   c                 (   t          | t          t          f          rat          | t                    r|                     d          n| }t	          |          }|rdt          |          ini }|t          |          fS t          | t                    r8t          |           }|ddi}ndt          |          i}|t          |           fS t          | t                    rddi}|t          |           fS t          dt          |                     )Nutf-8Content-LengthzTransfer-EncodingchunkedzUnexpected type for 'content', )
isinstancer.   strencodelenr   r   r   r1   r   r>   	TypeErrortype)rH   bodycontent_lengthheaderscontent_length_or_nones        r#   encode_contentrW   O   s     'E3<(( 9*4Wc*B*BOw~~g&&&T=AI#S%8%899r
4((((	GX	&	& 9!5g!>!>!)*I6GG'-C)D)DEG*73333	G]	+	+ 9&	2/8888
Gd7mmGG
H
HHr%   datac                    g }|                                  D ]g\  }t          |t          t          f          r"|                    fd|D                        C|                    t          |          f           ht          |d                              d          }t          t          |                    }d}||d}|t          |          fS )Nc                 2    g | ]}t          |          fS r/   )r   ).0itemkeys     r#   
<listcomp>z*encode_urlencoded_data.<locals>.<listcomp>o   s'    UUUt%;D%A%ABUUUr%   T)doseqrJ   z!application/x-www-form-urlencodedrK   zContent-Type)itemsrM   listtupleextendappendr   r   rO   rN   rP   r   )rX   
plain_datavaluerS   rT   content_typerU   r]   s          @r#   encode_urlencoded_datari   i   s     Jjjll D D
UedE]++ 	DUUUUuUUUVVVVs$:5$A$ABCCCCZt,,,33G<<DT^^N6L!/NNGJt$$$$r%   filesboundaryc                 V    t          | ||          }|                                }||fS )N)rX   rj   rk   )r   get_headers)rX   rj   rk   	multipartrU   s        r#   encode_multipart_dataro   y   s4      TJJJI##%%GIr%   textc                     |                      d          }t          t          |                    }d}||d}|t          |          fS )NrJ   ztext/plain; charset=utf-8r`   rO   rN   rP   r   )rp   rS   rT   rh   rU   s        r#   encode_textrs      sI    ;;wDT^^N.L!/NNGJt$$$$r%   htmlc                     |                      d          }t          t          |                    }d}||d}|t          |          fS )NrJ   ztext/html; charset=utf-8r`   rr   )rt   rS   rT   rh   rU   s        r#   encode_htmlrv      sI    ;;wDT^^N-L!/NNGJt$$$$r%   jsonc                     t          |                               d          }t          t          |                    }d}||d}|t	          |          fS )NrJ   zapplication/jsonr`   )
json_dumpsrO   rN   rP   r   )rw   rS   rT   rh   rU   s        r#   encode_jsonrz      sS    d""7++DT^^N%L!/NNGJt$$$$r%   c                 8   |@t          |t                    s+d}t          j        |t                     t          |          S | t          |           S |rt          |pi ||          S |rt          |          S |t          |          S i t          d          fS )z
    Handles encoding the given `content`, `data`, `files`, and `json`,
    returning a two-tuple of (<headers>, <stream>).
    Nz5Use 'content=<...>' to upload raw bytes/text content.r%   )
rM   dictwarningswarnDeprecationWarningrW   ro   ri   rz   r   )rH   rX   rj   rw   rk   messages         r#   encode_requestr      s     
4 6 6 Jg1222d###g&&&	 !$TZRAAA	 !%d+++		4   z#r%   c                     | t          |           S |t          |          S |t          |          S |t          |          S i t	          d          fS )zc
    Handles encoding the given `content`, returning a two-tuple of
    (<headers>, <stream>).
    Nr%   )rW   rs   rv   rz   r   )rH   rp   rt   rw   s       r#   encode_responser      se     g&&&		4   		4   		4   z#r%   r   )NNNNN)NNNN)/r5   r}   rw   r   ry   typingr   r   r   r   r   r	   r
   r   urllib.parser   _exceptionsr   r   
_multipartr   _transports.baser   r   _typesr   r   r   r   _utilsr   r   r   r1   r>   rC   rN   r.   rW   r|   ri   ro   rs   rv   rz   r   r   r/   r%   r#   <module>r      sD     $ $ $ $ $ $	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 # " " " " " 5 5 5 5 5 5 5 5 ' ' ' ' ' ' = = = = = = = = N N N N N N N N N N N N @ @ @ @ @ @ @ @    .              o          I3xe0DDEI
4S>5!@AABI I I I4%
%
4S>:%&% % % %" 8< 
#/4
4S>?*+   %c %eDcNJ$>? % % % %%c %eDcNJ$>? % % % %%c %eDcNJ$>? % % % % #    
    	 
   4S>5!@AAB       H  $	 
  	
 4S>5!@AAB     r%   