o
    ͷ6i                     @   s   d dl Z d dlmZ d dlmZmZmZmZmZ ddl	m
Z
mZmZ defddZG d	d
 d
eZG dd de jZG dd dZG dd dZdS )    N)TracebackType)IteratorCallableListTupleType   )URLHeadersTimeoutDictreturnc                   c   s    dV  d S )N     r   r   r   X/var/www/hoanhtaovolam_webdjango/env/lib/python3.10/site-packages/httpcore/_sync/base.pyempty   s   
r   c                   @   s   e Zd ZdS )NewConnectionRequiredN)__name__
__module____qualname__r   r   r   r   r      s    r   c                   @   s(   e Zd ZdZdZdZdZdZdZdZ	dS )	ConnectionStatez
    PENDING  READY
        |    |   ^
        v    V   |
        ACTIVE   |
         |  |    |
         |  V    |
         V  IDLE-+
       FULL   |
         |    |
         V    V
         CLOSED
    r      r            N)
r   r   r   __doc__PENDINGREADYACTIVEFULLIDLECLOSEDr   r   r   r   r      s    r   c                   @   sJ   e Zd ZdZ	ddee deddfddZdee fdd	Zdd
dZ	dS )SyncByteStreamz
    The base interface for request and response bodies.

    Concrete implementations should subclass this class, and implement
    the `\__iter__` method, and optionally the `close` method.
    Niterator
close_funcr   c                 C   s   |d u rt  n|| _|| _d S N)r   r"   r#   )selfr"   r#   r   r   r   __init__/   s   
zSyncByteStream.__init__c                 c   s    | j D ]}|V  qdS )zH
        Yield bytes representing the request or response body.
        N)r"   )r%   chunkr   r   r   __iter__5   s   
zSyncByteStream.__iter__c                 C   s   | j dur|    dS dS )z[
        Must be called by the client to indicate that the stream has been closed.
        N)r#   r%   r   r   r   close<   s   
zSyncByteStream.close)NNr   N)
r   r   r   r   r   bytesr   r&   r(   r*   r   r   r   r   r!   '   s    
r!   c                   @   s   e Zd ZdZ			ddededededede	ee
eee	eef  ef fd	d
ZdddZdddZ			ddee dededdfddZdS )SyncHTTPTransportz
    The base interface for sending HTTP requests.

    Concete implementations should subclass this class, and implement
    the `request` method, and optionally the `close` method.
    Nmethodurlheadersstreamtimeoutr   c                 C   s   t  )ab  
        The interface for sending a single HTTP request, and returning a response.

        **Parameters:**

        * **method** - `bytes` - The HTTP method, such as `b'GET'`.
        * **url** - `Tuple[bytes, bytes, Optional[int], bytes]` - The URL as a 4-tuple of
        (scheme, host, port, path).
        * **headers** - `Optional[List[Tuple[bytes, bytes]]]` - Any HTTP headers
        to send with the request.
        * **stream** - `Optional[SyncByteStream]` - The body of the HTTP request.
        * **timeout** - `Optional[Dict[str, Optional[float]]]` - A dictionary of
        timeout values for I/O operations.

        ** Returns:**

        A five-tuple of:

        * **http_version** - `bytes` - The HTTP version used by the server,
        such as `b'HTTP/1.1'`.
        * **status_code** - `int` - The HTTP status code, such as `200`.
        * **reason_phrase** - `bytes` - Any HTTP reason phrase, such as `b'OK'`.
        * **headers** - `List[Tuple[bytes, bytes]]` - Any HTTP headers included
        on the response.
        * **stream** - `SyncByteStream` - The body of the HTTP response.
        )NotImplementedError)r%   r.   r/   r0   r1   r2   r   r   r   requestL   s   "zSyncHTTPTransport.requestc                 C   s   dS )z
        Close the implementation, which should close any outstanding response streams,
        and any keep alive connections.
        Nr   r)   r   r   r   r*   p   s    zSyncHTTPTransport.closec                 C   s   | S r$   r   r)   r   r   r   	__enter__v   s   zSyncHTTPTransport.__enter__exc_type	exc_value	tracebackc                 C   s   |    d S r$   )r*   )r%   r6   r7   r8   r   r   r   __exit__y   s   zSyncHTTPTransport.__exit__)NNNr+   )r   r-   )r   r   r   r   r,   r	   r
   r!   r   r   intr   r4   r*   r5   r   BaseExceptionr   r9   r   r   r   r   r-   D   s@    

$
r-   )enumtypesr   typingr   r   r   r   r   _typesr	   r
   r   r   	Exceptionr   IntEnumr   r!   r-   r   r   r   r   <module>   s    