B
    ²ô`m  ã               @   s~   d dl Z d dlmZ d dlmZmZmZ ddlmZm	Z	m
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ÚTupleÚTypeé   )ÚURLÚHeadersÚTc               @   s   e Zd ZdS )ÚNewConnectionRequiredN)Ú__name__Ú
__module__Ú__qualname__© r   r   úB/home/dcms/DCMS/lib/python3.7/site-packages/httpcore/_sync/base.pyr
      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__ZPENDINGZREADYZACTIVEZFULLZIDLEZCLOSEDr   r   r   r   r      s   r   c               @   s0   e Zd ZdZee dœdd„Zd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.
    )Úreturnc             c   s
   dV  dS )zH
        Yield bytes representing the request or response body.
        ó    Nr   )Úselfr   r   r   Ú__iter__+   s    zSyncByteStream.__iter__Nc             C   s   dS )z[
        Must be called by the client to indicate that the stream has been closed.
        Nr   )r   r   r   r   Úclose1   s    zSyncByteStream.close)r   r   r   r   r   Úbytesr   r   r   r   r   r   r   #   s   r   c               @   sn   e Zd ZdZdeeeeee	e
eeef dœdd„Zddœdd„Zeed	œd
d„Zdee eeddœ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Úextr   c             C   s
   t ƒ ‚dS )a¸  
        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.
        * **ext** - `Optional[dict]` - A dictionary of optional extensions.

        ** Returns:**

        A four-tuple of:

        * **status_code** - `int` - The HTTP status code, such as `200`.
        * **headers** - `List[Tuple[bytes, bytes]]` - Any HTTP headers included
        on the response.
        * **stream** - `SyncByteStream` - The body of the HTTP response.
        * **ext** - `dict` - A dictionary of optional extensions.
        N)ÚNotImplementedError)r   r   r   r    r!   r"   r   r   r   Úrequest@   s    zSyncHTTPTransport.request)r   c             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   a   s    zSyncHTTPTransport.close)r   r   c             C   s   | S )Nr   )r   r   r   r   Ú	__enter__g   s    zSyncHTTPTransport.__enter__)Úexc_typeÚ	exc_valueÚ	tracebackr   c             C   s   |   ¡  d S )N)r   )r   r&   r'   r(   r   r   r   Ú__exit__j   s    zSyncHTTPTransport.__exit__)NNN)NNN)r   r   r   r   r   r   r   r   Údictr   Úintr$   r   r	   r%   r   ÚBaseExceptionr   r)   r   r   r   r   r   8   s       r   )ÚenumÚtypesr   Útypingr   r   r   Ú_typesr   r   r	   Ú	Exceptionr
   ÚIntEnumr   r   r   r   r   r   r   Ú<module>   s   