
    6i                     .   U d dl mZ d dl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 ej                  rd d	lmZ d
Z eg d      ZdZ	 	 d dlZedz  Z	 ej.                  dk\  rd dlmZ nd dlmZ edz  Z G d de      Zej:                  Zded<   ej@                  e!ef   Z"h dZ#	 	 	 	 	 	 d	 	 	 	 	 	 	 	 	 	 	 	 	 ddZ$	 	 	 	 	 	 ddZ%ddZ& G d dejN                        Z(	 	 	 	 	 	 	 	 d dZ)y# e$ r d dlZY w xY w# e$ r Y w xY w# e$ r Y w xY w)!    )annotationsN)	b64encode)Enum   )UnrewindableBodyError   )to_bytes)Finalz@@@SKIP_HEADER@@@)accept-encodinghost
user-agentzgzip,deflatez,br)      )zstdz,zstdc                      e Zd ZdZy)_TYPE_FAILEDTELLr   N)__name__
__module____qualname__token     W/home/azureuser/techstart-app/venv/lib/python3.12/site-packages/urllib3/util/request.pyr   r   ,   s    Er   r   zFinal[_TYPE_FAILEDTELL]_FAILEDTELL>   GETHEADTRACEDELETECONNECTOPTIONSc                t   i }|r>t        |t              rn(t        |t              rdj                  |      }nt        }||d<   |r||d<   | rd|d<   |r.dt        |j                  d            j                          |d<   |r.dt        |j                  d            j                          |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 the dependencies for
        Brotli (either the ``brotli`` or ``brotlicffi`` package) and/or
        Zstandard (the ``backports.zstd`` package for Python before 3.14)
        algorithms are installed, then their encodings are
        included in the string ('br' and 'zstd', respectively).
        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)
keep_aliveaccept_encoding
user_agent
basic_authproxy_basic_authdisable_cacheheaderss          r   make_headersr3   <   s    d !Gos+.!hh7O-O%4!" * ,Yz00;<CCEFG 	  Y/66yABIIKLM 	%& #- Nr   c                    |t        | |       |S t        | dd      	 | j                         }|S |S # t        $ r
 t        }Y |S w xY w)z
    If a position is provided, move file to that point.
    Otherwise, we'll attempt to record a position for future use.
    Ntell)rewind_bodygetattrr5   OSErrorr   )bodyposs     r   set_file_positionr;      sc     D# J 
vt	$	0	))+C J3J  	 CJ	s   3 AAc                    t        | dd      }|t        |t              r
	  ||       y|t
        u rt	        d      t        dt        |       d      # t        $ r}t	        d      |d}~ww xY w)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.
    seekNzAAn error occurred when rewinding request body for redirect/retry.zRUnable to record file position for rewinding request body during a redirect/retry.z1body_pos must be of type integer, instead it was .)r7   r%   intr8   r   r   
ValueErrortype)r9   body_pos	body_seekes       r   r6   r6      s     fd+IHc!:	h
 
[	 #4
 	

 ?X?OqQ
 	
  	'S	s   A 	A/A**A/c                  "    e Zd ZU ded<   ded<   y)ChunksAndContentLengthztyping.Iterable[bytes] | Nonechunksz
int | Nonecontent_lengthN)r   r   r   __annotations__r   r   r   rF   rF      s    ))r   rF   c                     d}|j                         t        vrd}nld}nit         t        t        f      rt               f}t        |d         }n8t         d      rd fd} |       }d}n	 t               } f}|j                  }t        ||      S # t        $ r. 	 t               }d}n# t        $ r t        d       dw xY wY Cw xY w)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   readc               3     K   t        t        j                        } 	 j                        }|sy | r|j	                  d      }| ,w)Nzutf-8)r%   io
TextIOBaserK   r*   )r*   	datablock	blocksizer9   s     r   chunk_readablez&body_to_chunks.<locals>.chunk_readable   sK     bmm4F IIi0	  ) 0 0 9I s   AAzO'body' must be a bytes-like object, file-like object, or iterable. Instead was )rG   rH   )returnztyping.Iterable[bytes])upper_METHODS_NOT_EXPECTING_BODYr%   r&   bytesr	   lenhasattr
memoryviewnbytes	TypeErroriterrF   )r9   methodrP   rG   rH   rQ   mvs   ` `    r   body_to_chunksr^      s    $ |<<>!<<N!N 
D3,	'4."VAY 
v		   !	'D!B WFYYN!OO  		d!% 88<xA  			s*   2B 	C#B10C1C

CC)NNNNNN)r,   bool | Noner-   zbool | list[str] | str | Noner.   
str | Noner/   r`   r0   r`   r1   r_   rR   zdict[str, str])r9   z
typing.Anyr:   _TYPE_BODY_POSITION | NonerR   ra   )r9   ztyping.IO[typing.AnyStr]rB   _TYPE_BODY_POSITIONrR   None)r9   ztyping.Any | Noner\   r&   rP   r?   rR   rF   )*
__future__r   rM   systypingbase64r   enumr   
exceptionsr   utilr	   TYPE_CHECKINGr
   SKIP_HEADER	frozensetSKIPPABLE_HEADERSr)   
brotlicffi_unused_module_brotliImportErrorbrotliversion_infocompressionr   _unused_module_zstd	backportsr   r   r   rI   Unionr?   rb   rT   r3   r;   r6   
NamedTuplerF   r^   r   r   r   <module>ry      s   " 	 
    . 	 "GH  /2 uO
7";9 wOt  (8'='=$ =ll3(8#89  W  #59!!#'!%OO2O O 	O
 !O O Od
5(
<V.. 
BP
BP%(BP58BPBPW  /./ 		  		s<   C2 D 2	C>;D =C>>D D	D	DD