
    osj9                       d dl m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mZmZm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mZ dd
lmZ ej:                  r
d dlZddlm Z  g dZ!dddddddddedddd	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 ddZ"edddddddddedddd	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 d d       Z#dddddddedd		 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 d!dZ$dddddddedd		 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 d!dZ%dddddddedd		 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 d!dZ&dddddddddddedd	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 d"dZ'dddddddddddedd	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 d"dZ(dddddddddddedd	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 d"dZ)ddddddeddd		 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 d#dZ*dddddddddddedd	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 d"dZ+eddddddedddeee
ed	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 d$d       Z,y)%    )annotationsN)	Generator)contextmanager   )Client)'DEFAULT_KEEPALIVE_PING_INTERVAL_SECONDS&DEFAULT_KEEPALIVE_PING_TIMEOUT_SECONDSDEFAULT_MAX_MESSAGE_SIZE_BYTESDEFAULT_QUEUE_SIZEDEFAULT_TIMEOUT_CONFIG)Response)		AuthTypesCookieTypesHeaderTypes
ProxyTypesQueryParamTypesRequestContentRequestDataRequestFilesTimeoutTypes)URL)WebSocketSession)deletegetheadoptionspatchpostputqueryrequeststream	websocketFT)paramscontentdatafilesjsonheaderscookiesauthproxytimeoutfollow_redirectsverify	trust_envc                   t        ||
|||      5 }|j                  | ||||||||	|
      cddd       S # 1 sw Y   yxY w)a  Sends an HTTP request.

    Parameters:
        method: HTTP method for the new `Request` object: `GET`, `OPTIONS`, `HEAD`, `POST`, `PUT`, `PATCH`, `DELETE`,
            or `QUERY`.
        url: URL for the new `Request` object.
        params: *(optional)* Query parameters to include in the URL, as a string, dictionary, or sequence of two-tuples.
        content: *(optional)* Binary content to include in the body of the request, as bytes or a byte iterator.
        data: *(optional)* Form data to include in the body of the request, as a dictionary.
        files: *(optional)* A dictionary of upload files to include in the body of the request.
        json: *(optional)* A JSON serializable object to include in the body of the request.
        headers: *(optional)* Dictionary of HTTP headers to include in the request.
        cookies: *(optional)* Dictionary of Cookie items to include in the request.
        auth: *(optional)* An authentication class to use when sending the request.
        proxy: *(optional)* A proxy URL where all the traffic should be routed.
        timeout: *(optional)* The timeout configuration to use when sending the request.
        follow_redirects: *(optional)* Enables or disables HTTP redirects.
        verify: *(optional)* Either `True` to use an SSL context with the default CA bundle, `False` to disable
            verification, or an instance of `ssl.SSLContext` to use a custom context.
        trust_env: *(optional)* Enables or disables usage of environment variables for configuration.

    Returns:
        The `Response` object.

    Usage:

    ```
    >>> import httpx2
    >>> response = httpx2.request('GET', 'https://httpbin.org/get')
    >>> response
    <Response [200 OK]>
    ```
    r*   r,   r/   r-   r0   
methodurlr%   r&   r'   r(   r$   r)   r+   r.   N)r   r!   )r4   r5   r$   r%   r&   r'   r(   r)   r*   r+   r,   r-   r.   r/   r0   clients                   >/root/.hermes/venv/lib/python3.12/site-packages/httpx2/_api.pyr!   r!   2   se    f 

 
 
~~-  

 
 
s   6?c             #     K   t        ||
|||      5 }|j                  | ||||||||	|
      5 }| ddd       ddd       y# 1 sw Y   xY w# 1 sw Y   yxY ww)z
    Alternative to `httpx2.request()` that streams the response body
    instead of loading it into memory at once.

    **Parameters**: See `httpx2.request`.

    See also: [Streaming Responses][0]

    [0]: /quickstart#streaming-responses
    r2   r3   N)r   r"   )r4   r5   r$   r%   r&   r'   r(   r)   r*   r+   r,   r-   r.   r/   r0   r6   responses                    r7   r"   r"   z   s     : 

  
]]-  
 	 N	 	 	 1   AAAA	AA	
AAA	r$   r)   r*   r+   r,   r.   r/   r-   r0   c       	        .    t        d| |||||||||	      S )z
    Sends a `GET` request.

    **Parameters**: See `httpx2.request`.

    Note that the `data`, `files`, `json` and `content` parameters are not available
    on this function, as `GET` requests should not include a request body.
    GETr;   r!   
r5   r$   r)   r*   r+   r,   r.   r/   r-   r0   s
             r7   r   r      s2    * )     c       	        .    t        d| |||||||||	      S )z
    Sends an `OPTIONS` request.

    **Parameters**: See `httpx2.request`.

    Note that the `data`, `files`, `json` and `content` parameters are not available
    on this function, as `OPTIONS` requests should not include a request body.
    OPTIONSr;   r>   r?   s
             r7   r   r      s2    * ) r@   c       	        .    t        d| |||||||||	      S )z
    Sends a `HEAD` request.

    **Parameters**: See `httpx2.request`.

    Note that the `data`, `files`, `json` and `content` parameters are not available
    on this function, as `HEAD` requests should not include a request body.
    HEADr;   r>   r?   s
             r7   r   r      s2    * ) r@   r%   r&   r'   r(   r$   r)   r*   r+   r,   r.   r/   r-   r0   c               6    t        d| |||||||||	|
|||      S )zL
    Sends a `POST` request.

    **Parameters**: See `httpx2.request`.
    POSTrE   r>   r5   r%   r&   r'   r(   r$   r)   r*   r+   r,   r.   r/   r-   r0   s                 r7   r   r     s>    , ) r@   c               6    t        d| |||||||||	|
|||      S )zK
    Sends a `PUT` request.

    **Parameters**: See `httpx2.request`.
    PUTrE   r>   rH   s                 r7   r   r   B  s>    , ) r@   c               6    t        d| |||||||||	|
|||      S )zM
    Sends a `PATCH` request.

    **Parameters**: See `httpx2.request`.
    PATCHrE   r>   rH   s                 r7   r   r   k  >    , ) r@   )	r$   r)   r*   r+   r,   r.   r-   r/   r0   c       	        .    t        d| |||||||||	      S )z
    Sends a `DELETE` request.

    **Parameters**: See `httpx2.request`.

    Note that the `data`, `files`, `json` and `content` parameters are not available
    on this function, as `DELETE` requests should not include a request body.
    DELETEr;   r>   )
r5   r$   r)   r*   r+   r,   r.   r-   r/   r0   s
             r7   r   r     s2    * ) r@   c               6    t        d| |||||||||	|
|||      S )zM
    Sends a `QUERY` request.

    **Parameters**: See `httpx2.request`.
    QUERYrE   r>   rH   s                 r7   r    r      rM   r@   )r$   r)   r*   r+   r,   r.   r-   r/   r0   subprotocolsmax_message_size_bytes
queue_sizekeepalive_ping_interval_secondskeepalive_ping_timeout_secondsc             #     K   t        |||||	      5 }|j                  | |||||
||||
      5 }| ddd       ddd       y# 1 sw Y   xY w# 1 sw Y   yxY ww)aL  
    Open a WebSocket session.

    The session is closed automatically when exiting the context manager.

    ```python
    with httpx2.websocket("ws://localhost:8000/ws") as ws:
        ws.send_text("Hello!")
        message = ws.receive_text()
    ```

    **Parameters**: See `httpx2.request` and `httpx2.Client.websocket`.
    r2   )	r$   r)   r+   r.   rR   rS   rT   rU   rV   N)r   r#   )r5   r$   r)   r*   r+   r,   r.   r-   r/   r0   rR   rS   rT   rU   rV   r6   sessions                    r7   r#   r#     s     @ 

  
-%#9!,K+I  
 	 M	 	 	 r:   ) r4   strr5   	URL | strr$   QueryParamTypes | Noner%   RequestContent | Noner&   RequestData | Noner'   RequestFiles | Noner(   typing.Any | Noner)   HeaderTypes | Noner*   CookieTypes | Noner+   AuthTypes | Noner,   ProxyTypes | Noner-   r   r.   boolr/   ssl.SSLContext | str | boolr0   rd   returnr   ) r4   rY   r5   rZ   r$   r[   r%   r\   r&   r]   r'   r^   r(   r_   r)   r`   r*   ra   r+   rb   r,   rc   r-   r   r.   rd   r/   re   r0   rd   rf   zGenerator[Response])r5   rZ   r$   r[   r)   r`   r*   ra   r+   rb   r,   rc   r.   rd   r/   re   r-   r   r0   rd   rf   r   )r5   rZ   r%   r\   r&   r]   r'   r^   r(   r_   r$   r[   r)   r`   r*   ra   r+   rb   r,   rc   r.   rd   r/   re   r-   r   r0   rd   rf   r   )r5   rZ   r$   r[   r)   r`   r*   ra   r+   rb   r,   rc   r.   rd   r-   r   r/   re   r0   rd   rf   r   ) r5   rZ   r$   r[   r)   r`   r*   ra   r+   rb   r,   rc   r.   rd   r-   r   r/   re   r0   rd   rR   zlist[str] | NonerS   intrT   rg   rU   float | NonerV   rh   rf   zGenerator[WebSocketSession])-
__future__r   typingcollections.abcr   
contextlibr   _clientr   _configr   r	   r
   r   r   _modelsr   _typesr   r   r   r   r   r   r   r   r   _urlsr   TYPE_CHECKINGsslwebsockets._apir   __all__r!   r"   r   r   r   r   r   r   r   r    r#    r@   r7   <module>rw      s)   "  % %   
 
 
 	1& &*%)#!%""&"&!#2"*.!E
E
	E
 #	E

 #E
 E
 E
 E
  E
  E
 E
 E
 E
 E
 (E
  !E
" #E
P 
 &*%)#!%""&"&!#2"*.!//	/ #	/
 #/ / / /  /  / / / / / (/  !/" #/ /j &*"&"&!#"*.2!	! #!  	!
  ! ! ! ! (! ! ! !N &*"&"&!#"*.2!	! #!  	!
  ! ! ! ! (! ! ! !N &*"&"&!#"*.2!	! #!  	!
  ! ! ! ! (! ! ! !N &*#!%"%)"&"&!#"*.2&	& #& 	&
 & & #&  &  & & & & (& & &  !&X &*#!%"%)"&"&!#"*.2&	& #& 	&
 & & #&  &  & & & & (& & &  !&X &*#!%"%)"&"&!#"*.2&	& #& 	&
 & & #&  &  & & & & (& & &  !&X &*"&"&!#"2*.!	! #!  	!
  ! ! ! ! ! (! ! !N &*#!%"%)"&"&!#"*.2&	& #& 	&
 & & #&  &  & & & & (& & &  !&R  &*"&"&!#"2*.%)"@(4[3Y!2	2 #2  	2
  2 2 2 2 2 (2 2 #2  2 2 &22  %1!2" !#2 2r@   