
    j'                       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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	 ej        dk    rd dlmZ nd dlm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<   ej         e!ef         Z"h dZ#	 	 	 	 	 	 d8dddd9d&Z$d:d+Z%d;d0Z& G d1 d2ej'                  Z(d<d7Z)dS )=    )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dS )_TYPE_FAILEDTELLr   N)__name__
__module____qualname__token     C/opt/deyu/venv/lib/python3.11/site-packages/urllib3/util/request.pyr   r   ,   s        EEEr   r   zFinal[_TYPE_FAILEDTELL]_FAILEDTELL>   GETHEADTRACEDELETECONNECTOPTIONSzlatin-1)basic_auth_encodingproxy_basic_auth_encoding
keep_alivebool | Noneaccept_encodingbool | list[str] | str | None
user_agent
str | None
basic_authproxy_basic_authdisable_cacher!   strr"   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<   |r:dt          |                    |                                                     |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. Basic authentication transmits Base64-encoded bytes, not
        Unicode text, so the string is encoded with ``basic_auth_encoding``
        before Base64 encoding.

        Must contain decoded credentials (not percent-encoded).
        For URLs parsed with :func:`parse_url`, use :attr:`Url.auth_decoded_joined`
        to get the properly formatted string.

    :param basic_auth_encoding:
        Text encoding used to encode ``basic_auth`` before Base64 encoding.
        Defaults to "latin-1" for backward compatibility. Use "utf-8" only
        when the peer expects UTF-8 Basic authentication credentials.

        Must contain decoded credentials (not percent-encoded).
        For URLs parsed with :func:`parse_url`, use :attr:`Url.auth_decoded_joined`
        to get the properly formatted string.

    :param proxy_basic_auth:
        Colon-separated username:password string for 'proxy-authorization: basic ...'
        auth header. Basic authentication transmits Base64-encoded bytes, not
        Unicode text, so the string is encoded with ``proxy_basic_auth_encoding``
        before Base64 encoding.

        Must contain decoded credentials (not percent-encoded).
        For URLs parsed with :func:`parse_url`, use :attr:`Url.auth_decoded_joined`
        to get the properly formatted string.

    :param proxy_basic_auth_encoding:
        Text encoding used to encode ``proxy_basic_auth`` before Base64
        encoding. Defaults to "latin-1" for backward compatibility. Use
        "utf-8" only when the proxy expects UTF-8 Basic authentication
        credentials.

        Must contain decoded credentials (not percent-encoded).
        For URLs parsed with :func:`parse_url`, use :attr:`Url.auth_decoded_joined`
        to get the properly formatted string.

    :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 authorizationzproxy-authorizationzno-cachezcache-control)
isinstancer,   listjoinACCEPT_ENCODINGr   encodedecode)	r#   r%   r'   r)   r*   r+   r!   r"   headerss	            r   make_headersr:   <   s   h !G 5os++ 	... 	.!hh77OO-O%4!" + * - , 
QYz001DEEFFMMOOQQ 	   
]Y/667PQQRRYY[[]] 	%&  .#- Nr   body
typing.Any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.
    Ntell)rewind_bodygetattrr@   OSErrorr   )r;   r=   s     r   set_file_positionrD      so     D#	vt	$	$	0	))++CC 	 	 	 CCC	
 Js   ; AAtyping.IO[typing.AnyStr]body_pos_TYPE_BODY_POSITIONNonec                D   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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.
    seekNzAAn error occurred when rewinding request body for redirect/retry.zRUnable to record file position for rewinding request body during a redirect/retry.zbody does not implement seek.z1body_pos must be of type integer, instead it was .)rB   r3   intrC   r   r   
ValueErrortype)r;   rF   	body_seekes       r   rA   rA      s     fd++IHc!:!:	Ih 	 	 	'S 	 
[	 	 #4
 
 	
 
	#$CDDDQXQQQ
 
 	
s   7 
AAAc                  $    e Zd ZU ded<   ded<   dS )ChunksAndContentLengthztyping.Iterable[bytes] | Nonechunksz
int | Nonecontent_lengthN)r   r   r   __annotations__r   r   r   rR   rR      s*         ))))r   rR   typing.Any | Nonemethod	blocksizerL   c                     #d}|                                 t          vrd}nd}nt           t          t          f          r&t                     f}t          |d                   }nt           d          rd	 fd} |            }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          ||          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   readr-   typing.Iterable[bytes]c               3     K   t          t          j                  } 	                               }|sd S | r|                    d          }|V  5)NTzutf-8)r3   io
TextIOBaserZ   r7   )r7   	datablockrX   r;   s     r   chunk_readablez&body_to_chunks.<locals>.chunk_readable
  sd      bm44F  IIi00	  E : ) 0 0 9 9I r   zO'body' must be a bytes-like object, file-like object, or iterable. Instead was )rS   rT   )r-   r[   )upper_METHODS_NOT_EXPECTING_BODYr3   r,   bytesr	   lenhasattr
memoryviewnbytes	TypeErroriterrR   )r;   rW   rX   rS   rT   r`   mvs   ` `    r   body_to_chunksrk      sq   $ |<<>>!<<<NN!NN 
D3,	'	' &'4.."VAY 
v		 !'	  	  	  	  	  	  	   !!	'D!!B WFYNN  		 		 		d!%   A8<A A   			 "OOOOs*   B) )
C*4CC*C$$C*)C*)NNNNNN)r#   r$   r%   r&   r'   r(   r)   r(   r*   r(   r+   r$   r!   r,   r"   r,   r-   r.   )r;   r<   r=   r>   r-   r>   )r;   rE   rF   rG   r-   rH   )r;   rV   rW   r,   rX   rL   r-   rR   )*
__future__r   r]   systypingbase64r   enumr   
exceptionsr   utilr	   TYPE_CHECKINGr
   SKIP_HEADER	frozensetSKIPPABLE_HEADERSr6   
brotlicffi_unused_module_brotliImportErrorbrotliversion_infocompressionr   _unused_module_zstd	backportsr   r   r   rU   UnionrL   rG   rb   r:   rD   rA   
NamedTuplerR   rk   r   r   r   <module>r      s   " " " " " " " 				 



              . . . . . .      	  "IGGGHH  /22222 / / /....../
 uOO  	 	 	D	

7"";;;;;;;999999 wOO  	 	 	D	    t    (8'= = = = =l3(8#89  WVV  #59!!#'!%q  )%.q q q q q qh   (
 
 
 
@    V.   
BP BP BP BP BP BPsB   A A& 	AA& AA& &A.-A.2B BB