U
    nËjß-  ã                   @  sô  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
 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dddddddg	Zdddddddddeddddœddddddddddd d!d"d#d"d$d%œd&d„Zedddddddddeddddœddddddddddd d!d"d#d"d'd%œd(d„ƒZdddddddedd)œ	dddddd d"d#d!d"d$d*œd+d„Zdddddddedd)œ	dddddd d"d#d!d"d$d*œd,d„Zdddddddedd)œ	dddddd d"d#d!d"d$d*œd-d„Zdddddddddddedd.œdddddddddd d"d#d!d"d$d/œd0d„Zdddddddddddedd.œdddddddddd d"d#d!d"d$d/œd1d„Z dddddddddddedd.œdddddddddd d"d#d!d"d$d/œd2d„Z!ddddddeddd3œ	dddddd d"d!d#d"d$d4œd5d
„Z"dS )6é    )ÚannotationsN)Úcontextmanageré   )ÚClient)ÚDEFAULT_TIMEOUT_CONFIG)ÚResponse)	Ú	AuthTypesÚCookieTypesÚHeaderTypesÚ
ProxyTypesÚQueryParamTypesÚRequestContentÚRequestDataÚRequestFilesÚTimeoutTypes)ÚURLÚdeleteÚgetÚheadÚoptionsÚpatchÚpostÚputÚrequestÚstreamFT)ÚparamsÚcontentÚdataÚfilesÚjsonÚheadersÚcookiesÚauthÚproxyÚtimeoutÚfollow_redirectsÚverifyÚ	trust_envÚstrz	URL | strzQueryParamTypes | NonezRequestContent | NonezRequestData | NonezRequestFiles | Noneztyping.Any | NonezHeaderTypes | NonezCookieTypes | NonezAuthTypes | NonezProxyTypes | Noner   Úboolzssl.SSLContext | str | boolr   )ÚmethodÚurlr   r   r   r   r   r    r!   r"   r#   r$   r%   r&   r'   Úreturnc                C  sH   t ||
|||d��,}|j| ||||||||	|d�
W  5 Q R £ S Q R X dS )a  
    Sends an HTTP request.

    **Parameters:**

    * **method** - HTTP method for the new `Request` object: `GET`, `OPTIONS`,
    `HEAD`, `POST`, `PUT`, `PATCH`, or `DELETE`.
    * **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:** `Response`

    Usage:

    ```
    >>> import httpx
    >>> response = httpx.request('GET', 'https://httpbin.org/get')
    >>> response
    <Response [200 OK]>
    ```
    ©r!   r#   r&   r$   r'   ©
r*   r+   r   r   r   r   r   r    r"   r%   N)r   r   )r*   r+   r   r   r   r   r   r    r!   r"   r#   r$   r%   r&   r'   Úclient© r0   ú./tmp/pip-unpacked-wheel-7ig9zwdf/httpx/_api.pyr   '   s(    ?ûöztyping.Iterator[Response]c                c  sR   t ||
|||d��6}|j| ||||||||	|d�
�}|V  W 5 Q R X W 5 Q R X dS )zô
    Alternative to `httpx.request()` that streams the response body
    instead of loading it into memory at once.

    **Parameters**: See `httpx.request`.

    See also: [Streaming Responses][0]

    [0]: /quickstart#streaming-responses
    r-   r.   N)r   r   )r*   r+   r   r   r   r   r   r    r!   r"   r#   r$   r%   r&   r'   r/   Úresponser0   r0   r1   r   {   s,    ûö©	r   r    r!   r"   r#   r%   r&   r$   r'   )r+   r   r    r!   r"   r#   r%   r&   r$   r'   r,   c       	   
      C  s   t d| |||||||||	d�S )zë
    Sends a `GET` request.

    **Parameters**: See `httpx.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.
    ÚGETr3   ©r   ©
r+   r   r    r!   r"   r#   r%   r&   r$   r'   r0   r0   r1   r   ®   s    õc       	   
      C  s   t d| |||||||||	d�S )zô
    Sends an `OPTIONS` request.

    **Parameters**: See `httpx.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.
    ÚOPTIONSr3   r5   r6   r0   r0   r1   r   Ò   s    õc       	   
      C  s   t d| |||||||||	d�S )zí
    Sends a `HEAD` request.

    **Parameters**: See `httpx.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.
    ÚHEADr3   r5   r6   r0   r0   r1   r   ö   s    õ©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&   r$   r'   r,   c                C  s&   t d| |||||||||	|
|||d�S )zK
    Sends a `POST` request.

    **Parameters**: See `httpx.request`.
    ÚPOSTr9   r5   ©r+   r   r   r   r   r   r    r!   r"   r#   r%   r&   r$   r'   r0   r0   r1   r     s"    ñc                C  s&   t d| |||||||||	|
|||d�S )zJ
    Sends a `PUT` request.

    **Parameters**: See `httpx.request`.
    ÚPUTr9   r5   r;   r0   r0   r1   r   C  s"    ñc                C  s&   t d| |||||||||	|
|||d�S )zL
    Sends a `PATCH` request.

    **Parameters**: See `httpx.request`.
    ÚPATCHr9   r5   r;   r0   r0   r1   r   l  s"    ñ)	r   r    r!   r"   r#   r%   r$   r&   r'   )r+   r   r    r!   r"   r#   r%   r$   r&   r'   r,   c       	   
      C  s   t d| |||||||||	d�S )zñ
    Sends a `DELETE` request.

    **Parameters**: See `httpx.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.
    ÚDELETEr3   r5   )
r+   r   r    r!   r"   r#   r%   r$   r&   r'   r0   r0   r1   r   •  s    õ)#Ú
__future__r   ÚtypingÚ
contextlibr   Z_clientr   Ú_configr   Z_modelsr   Ú_typesr   r	   r
   r   r   r   r   r   r   Z_urlsr   ÚTYPE_CHECKINGÚsslÚ__all__r   r   r   r   r   r   r   r   r   r0   r0   r0   r1   Ú<module>   s  ,÷ð0Tð25õ&'õ&'õ&'ñ.,ñ.,ñ.,õ