U
    Wi3                     @  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mZmZmZ dd	lmZ d
ddddddddg	Z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"d#d$d%d#d&d'd(dZe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"d#d$d%d#d)d'd*d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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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Zdddddddddddddedd0dddddddddd d!d#d%d$d"d#d&d1d2dZ dddddddddddddedd0dddddddddd d!d#d%d$d"d#d&d1d3dZ!dddddddddddddedd0dddddddddd d!d#d%d$d"d#d&d1d4d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,d5d
Z#dS )6    )annotationsN)contextmanager   )Client)DEFAULT_TIMEOUT_CONFIG)Response)	AuthTypes	CertTypesCookieTypesHeaderTypesProxiesTypes
ProxyTypesQueryParamTypesRequestContentRequestDataRequestFilesTimeoutTypesVerifyTypes)URLdeletegetheadoptionspatchpostputrequeststreamFT)paramscontentdatafilesjsonheaderscookiesauthproxyproxiestimeoutfollow_redirectsverifycert	trust_envstrz	URL | strzQueryParamTypes | NonezRequestContent | NonezRequestData | NonezRequestFiles | Noneztyping.Any | NonezHeaderTypes | NonezCookieTypes | NonezAuthTypes | NonezProxyTypes | NonezProxiesTypes | Noner   boolr   zCertTypes | Noner   )methodurlr   r   r    r!   r"   r#   r$   r%   r&   r'   r(   r)   r*   r+   r,   returnc                C  sL   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.
    * **proxies** - *(optional)* A dictionary mapping proxy keys to proxy URLs.
    * **timeout** - *(optional)* The timeout configuration to use when sending
    the request.
    * **follow_redirects** - *(optional)* Enables or disables HTTP redirects.
    * **verify** - *(optional)* SSL certificates (a.k.a CA bundle) used to
    verify the identity of requested hosts. Either `True` (default CA bundle),
    a path to an SSL certificate file, an `ssl.SSLContext`, or `False`
    (which will disable verification).
    * **cert** - *(optional)* An SSL certificate used by the requested host
    to authenticate the client. Either a path to an SSL certificate file, or
    two-tuple of (certificate file, key file), or a three-tuple of (certificate
    file, key file, password).
    * **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/   r0   r   r    r!   r"   r   r#   r%   r)   N)r   r   )r/   r0   r   r   r    r!   r"   r#   r$   r%   r&   r'   r(   r)   r*   r+   r,   client r5   P/home/afrizal/public_html/fastapi/venv/lib/python3.8/site-packages/httpx/_api.pyr   &   s,    Gztyping.Iterator[Response]c                c  sV   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
    r2   r3   N)r   r   )r/   r0   r   r   r    r!   r"   r#   r$   r%   r&   r'   r(   r)   r*   r+   r,   r4   responser5   r5   r6   r      s0    r   r#   r$   r%   r&   r'   r)   r+   r*   r(   r,   )r0   r   r#   r$   r%   r&   r'   r)   r+   r*   r(   r,   r1   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.
    GETr8   r   r0   r   r#   r$   r%   r&   r'   r)   r+   r*   r(   r,   r5   r5   r6   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.
    OPTIONSr8   r:   r;   r5   r5   r6   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.
    HEADr8   r:   r;   r5   r5   r6   r     s    r   r    r!   r"   r   r#   r$   r%   r&   r'   r)   r+   r*   r(   r,   )r0   r   r    r!   r"   r   r#   r$   r%   r&   r'   r)   r+   r*   r(   r,   r1   c                C  s*   t d| |||||||||	|
|||||dS )zK
    Sends a `POST` request.

    **Parameters**: See `httpx.request`.
    POSTr>   r:   r0   r   r    r!   r"   r   r#   r$   r%   r&   r'   r)   r+   r*   r(   r,   r5   r5   r6   r   3  s&    c                C  s*   t d| |||||||||	|
|||||dS )zJ
    Sends a `PUT` request.

    **Parameters**: See `httpx.request`.
    PUTr>   r:   r@   r5   r5   r6   r   `  s&    c                C  s*   t d| |||||||||	|
|||||dS )zL
    Sends a `PATCH` request.

    **Parameters**: See `httpx.request`.
    PATCHr>   r:   r@   r5   r5   r6   r     s&    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.
    DELETEr8   r:   r;   r5   r5   r6   r     s    )$
__future__r   typing
contextlibr   Z_clientr   _configr   Z_modelsr   _typesr   r	   r
   r   r   r   r   r   r   r   r   r   Z_urlsr   __all__r   r   r   r   r   r   r   r   r   r5   r5   r5   r6   <module>   s$  84^69*+*+*+202020