
    nbi'                       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 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"	 	 	 	 	 	 d8d9d"Z#d:d'Z$d;d,Z% G d- d.ej&                  Z'	 d<d=d7Z(dS )>    )annotationsN)	b64encode)Enum   )UnrewindableBodyError   )to_bytes)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     k/var/www/html/mdtn/previsions/meteo_cartes/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_headersr8   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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   )r9   r;   s     r   set_file_positionrB      so     D#	vt	$	$	0	))++CC 	 	 	 CCC	
 Js   ; 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.
    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 .)r@   r0   intrA   r   r   
ValueErrortype)r9   rD   	body_seekes       r   r?   r?      s     fd++IHc!:!:	Ih 	 	 	'S 	 
[	 	 #4
 
 	

 QXQQQ
 
 	
s   7 
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_lengthbool	is_stringN)r   r   r   __annotations__r   r   r   rO   rO      s1         GGGGOOOOOr   rO   Ftyping.Any | Nonemethodr1   	blocksizerI   forcerR   c           
     <     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)rP   rQ   rS   r*   typing.Iterable[bytes]c               3     K   t          t          j                  } 	                               }|sd S | r|                    d          }|V  5)NTutf-8)r0   io
TextIOBasereadr5   )r5   	datablockrW   r9   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__r_   Tr\   )hasattrr_   r0   r1   r5   r
   putget)r5   blockqueuerW   r9   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r_   rd   zO'body' must be a bytes-like object, file-like object, or iterable. Instead was )r*   rZ   )r*   rb   )upper_METHODS_NOT_EXPECTING_BODYrO   r0   r1   bytesr	   lenr]   BytesIOre   
memoryviewnbytes	TypeErroriterStringIOTextIOWrapper)
r9   rV   rW   rX   rP   rQ   ra   rj   	convertedmvs
   ` `       r   body_to_chunksrx      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+   )r9   r:   r;   r<   r*   r<   )r9   rC   rD   r   r*   rE   )F)
r9   rU   rV   r1   rW   rI   rX   rR   r*   rO   ))
__future__r   r]   typingbase64r   enumr   
exceptionsr   utilr	   responser
   TYPE_CHECKINGtyping_extensionsr   _typingr   SKIP_HEADER	frozensetSKIPPABLE_HEADERSNOT_FORWARDABLE_HEADERSr4   
brotlicffi_unused_module_brotliImportErrorbrotli	zstandard_unused_module_zstdr   r   r   rT   rl   r8   rB   r?   
NamedTuplerO   rx   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^   (
 
 
 
<    V.    	~ ~ ~ ~ ~ ~ ~sB   !A& %A; &	A2/A; 1A22A; ;BBB BB