
    i-                       U d dl mZ d dlZd dlZd dlmZ d dlmZ ddlm	Z	 ddl
mZmZ dd	lmZ ej        rd d
lmZ ddlmZ dZ eg d          Z eg d          ZdZ	 	 d dlZn# e$ r d dlZY nw xY wedz  Zn# e$ r Y nw xY w	 d dlZedz  Zn# e$ r Y nw xY w G d de          Zej         Z!de"d<   h dZ#	 	 	 	 	 	 d;d<d"Z$d=d&Z%d>d)Z&d>d*Z'd?d/Z(d@d0Z) G d1 d2ej*                  Z+	 dAdBd:Z,dS )C    )annotationsN)	b64encode)Enum   )UnrewindableBodyError   )to_bytesiscoroutinefunction)BytesQueueBuffer)Final)_TYPE_BODY_POSITIONz@@@SKIP_HEADER@@@)accept-encodinghost
user-agent)zcontent-encodingzcontent-languagezcontent-locationzcontent-typezcontent-lengthdigestzlast-modifiedzgzip,deflatez,brz,zstdc                      e Zd ZdZdS )_TYPE_FAILEDTELLr   N)__name__
__module____qualname__token     V/root/projects/butler/venv/lib/python3.11/site-packages/urllib3_future/util/request.pyr   r   5   s        EEEr   r   zFinal[_TYPE_FAILEDTELL]_FAILEDTELL>   GETHEADTRACEDELETECONNECTOPTIONS
keep_alivebool | Noneaccept_encodingbool | list[str] | str | None
user_agent
str | None
basic_authproxy_basic_authdisable_cachereturndict[str, str]c                   i }|rMt          |t                    rn2t          |t                    rd                    |          }nt          }||d<   |r||d<   | rd|d<   |r:dt          |                    d                                                     |d<   |r:dt          |                    d                                                     |d	<   |rd
|d<   |S )a  
    Shortcuts for generating request headers.

    :param keep_alive:
        If ``True``, adds 'connection: keep-alive' header.

    :param accept_encoding:
        Can be a boolean, list, or string.
        ``True`` translates to 'gzip,deflate'.  If either the ``brotli`` or
        ``brotlicffi`` package is installed 'gzip,deflate,br' is used instead.
        List will get joined by comma.
        String will be used as provided.

    :param user_agent:
        String representing the user-agent you want, such as
        "python-urllib3/0.6"

    :param basic_auth:
        Colon-separated username:password string for 'authorization: basic ...'
        auth header.

    :param proxy_basic_auth:
        Colon-separated username:password string for 'proxy-authorization: basic ...'
        auth header.

    :param disable_cache:
        If ``True``, adds 'cache-control: no-cache' header.

    Example:

    .. code-block:: python

        import urllib3

        print(urllib3.util.make_headers(keep_alive=True, user_agent="Batman/1.0"))
        # {'connection': 'keep-alive', 'user-agent': 'Batman/1.0'}
        print(urllib3.util.make_headers(accept_encoding=True))
        # {'accept-encoding': 'gzip,deflate'}
    ,r   r   z
keep-alive
connectionzBasic zlatin-1authorizationzproxy-authorizationzno-cachezcache-control)
isinstancestrlistjoinACCEPT_ENCODINGr   encodedecode)r"   r$   r&   r(   r)   r*   headerss          r   make_headersr9   D   s   ^ !G 5os++ 	... 	.!hh77OO-O%4!" + * - , 
GYz00;;<<CCEEGG 	   
MY/66yAABBIIKKMM 	%&  .#- Nr   body
typing.Anyboolc                @    t          t          | dd                     S )Ntellc                     d S )Nr   r   r   r   <lambda>zis_async_file.<locals>.<lambda>   s    T r   )r
   getattr)r:   s    r   is_async_filerB      s    wtV\\BBCCCr   pos_TYPE_BODY_POSITION | Nonec                    |t          | |           n>t          | dd          -	 |                                 }n# t          $ r
 t          }Y nw xY w|S )z
    If a position is provided, move file to that point.
    Otherwise, we'll attempt to record a position for future use.
    Nr>   )rewind_bodyrA   r>   OSErrorr   r:   rC   s     r   set_file_positionrI      so     D#	vt	$	$	0	))++CC 	 	 	 CCC	
 Js   ; AAc                   K   |t          | |           d{V  nDt          | dd          3	 |                                  d{V }n# t          $ r
 t          }Y nw xY w|S )z\
    Asynchronous variant for set_file_position when using anyio.AsyncFile for example.
    Nr>   )arewind_bodyrA   r>   rG   r   rH   s     r   aset_file_positionrL      s       4%%%%%%%%%%	vt	$	$	0			######CC 	 	 	 CCC	
 Js   A	 	AAtyping.IO[typing.AnyStr]body_posr   Nonec                "   t          | dd          }|Et          |t                    r0	  ||           dS # t          $ r}t	          d          |d}~ww xY w|t
          u rt	          d          t          dt          |           d          )z
    Attempt to rewind body to a certain position.
    Primarily used for request redirects and retries.

    :param body:
        File-like object that supports seek.

    :param int pos:
        Position to seek to in file.
    seekNAAn error occurred when rewinding request body for redirect/retry.RUnable to record file position for rewinding request body during a redirect/retry.1body_pos must be of type integer, instead it was .rA   r1   intrG   r   r   
ValueErrortyper:   rN   	body_seekes       r   rF   rF      s     fd++IHc!:!:	Ih 	 	 	'S 	 
[	 	 #4
 
 	

 QXQQQ
 
 	
s   7 
AAAc                2  K   t          | dd          }|Kt          |t                    r6	  ||           d{V  dS # t          $ r}t	          d          |d}~ww xY w|t
          u rt	          d          t          dt          |           d          )z+
    Async counterpart of rewind_body.
    rQ   NrR   rS   rT   rU   rV   rZ   s       r   rK   rK      s       fd++IHc!:!:	)H%%%%%%%%%%% 	 	 	'S 	 
[	 	 #4
 
 	

 QXQQQ
 
 	
s   ? 
A	AAc                  .    e Zd ZU ded<   ded<   ded<   dS )ChunksAndContentLengthz;typing.Iterable[bytes] | typing.AsyncIterable[bytes] | Nonechunksz
int | Nonecontent_lengthr<   	is_stringN)r   r   r   __annotations__r   r   r   r_   r_      s1         GGGGOOOOOr   r_   Ftyping.Any | Nonemethodr2   	blocksizerW   forcec           
     <     4d}|                                 t          vrd}nd}t          ||d          S d fd}d fd	}t           t          t
          f          rVt                     }t          |          }|r2t          |          k    rt          j	        |            |            }n|f}nt           d
          rt           d          s |            }d}n|t           d          r |            }d}n_	 t                     }	 f}|	j        }nD# t          $ r7 	 t                     }d}n!# t          $ r t          d           dw xY wY nw xY wt          ||t           t          t          j        t          j        f                    S )aR  Takes the HTTP request method, body, and blocksize and
    transforms them into an iterable of chunks to pass to
    socket.sendall() and an optional 'Content-Length' header.

    A 'Content-Length' of 'None' indicates the length of the body
    can't be determined so should use 'Transfer-Encoding: chunked'
    for framing instead.
    Nr   F)r`   ra   rb   r+   typing.Iterable[bytes]c               3     K   t          t          j                  } 	                               }|sd S | r|                    d          }|V  5)NTutf-8)r1   io
TextIOBasereadr6   )r6   	datablockrf   r:   s     r   chunk_readablez&body_to_chunks.<locals>.chunk_readable  sd      D"-00			),,I  6%,,W55	OOO	r   typing.AsyncIterable[bytes]c                $  K   t          d          sJ d } t          d          rT	                                d {V }|sd S | t          |t                    } | r|                    d          n|W V  St                      }2 3 d {V }| t          |t                    } |                    | r|                    d          n|           |                              W V  c6 |r|                              W V  |d S d S )N	__aiter__rn   Trk   )hasattrrn   r1   r2   r6   r   putget)r6   blockqueuerf   r:   s      r   chunk_areadablez'body_to_chunks.<locals>.chunk_areadable&  s     GD+$>$>"4   	+	A"ii	22222222 E>'s33F/5@ell7+++5@@@@	A %&&E# + + + + + + +e>'s33F		6D%,,w///uEEEii	*******	  $  +ii	******  + + + + +s   C1rn   rs   zO'body' must be a bytes-like object, file-like object, or iterable. Instead was )r+   ri   )r+   rq   )upper_METHODS_NOT_EXPECTING_BODYr_   r1   r2   bytesr	   lenrl   BytesIOrt   
memoryviewnbytes	TypeErroriterStringIOTextIOWrapper)
r:   re   rf   rg   r`   ra   rp   ry   	convertedmvs
   ` `       r   body_to_chunksr      sK   * |<<>>!<<<NN!N%)
 
 
 	
	 	 	 	 	 	 	+ + + + + + +B $e%% #'TNN	Y 	"S^^y00:i((D#^%%FF\FF 
v		 'wt['A'A '!!	{	#	# ' ""	'D!!B WFYNN  		 		 		d!%   A8<A A   			 "% 
 
   s*   D 
E)D;:E;EEE)NNNNNN)r"   r#   r$   r%   r&   r'   r(   r'   r)   r'   r*   r#   r+   r,   )r:   r;   r+   r<   )r:   r;   rC   rD   r+   rD   )r:   rM   rN   r   r+   rO   )r:   r;   rN   r   r+   rO   )F)
r:   rd   re   r2   rf   rW   rg   r<   r+   r_   )-
__future__r   rl   typingbase64r   enumr   
exceptionsr   utilr	   r
   responser   TYPE_CHECKINGtyping_extensionsr   _typingr   SKIP_HEADER	frozensetSKIPPABLE_HEADERSNOT_FORWARDABLE_HEADERSr5   
brotlicffi_unused_module_brotliImportErrorbrotli	zstandard_unused_module_zstdr   r   r   rc   r{   r9   rB   rI   rL   rF   rK   
NamedTupler_   r   r   r   r   <module>r      s   " " " " " " " 				              . . . . . . / / / / / / / / & & & & & &	 .''''''------ "IGGGHH #)  
 
  !/22222 / / /....../
 uOO  	 	 	D	++++ wOO  	 	 	D	    t    (8'= = = = = WVV  #59!!#'!%L L L L L^D D D D   (   &
 
 
 
<
 
 
 
.    V.    	~ ~ ~ ~ ~ ~ ~sB   #A( 'A= (	A41A= 3A44A= =BB	B BB