o
    h$                     @   s   d dl mZ d dlmZmZ g dZG dd deZG dd deZG dd	 d	eZ	G d
d de	Z
G dd de	ZG dd deZG dd deZG dd deZdS )   )_headers)bytesifyLocalProtocolError)RequestInformationalResponseResponseDataEndOfMessageConnectionClosedc                   @   s@   e Zd Zg Zi Zdd Zdd Zdd Zdd Zd	d
 Z	dZ
dS )_EventBundlec                 K   s   | dd}t| j}|D ]}||vrtd|| jjq|| j}|D ]}||vr6td|| jjq&| j	
| j | j	
| d| j	v rRtj| j|d| _|swdD ]}|| j	v rgt| j	| | j	|< qVd| j	v rwt| jtswtd	|   d S )
N_parsedFzunrecognized kwarg {} for {}z missing required kwarg {} for {}headers)r   )methodtargethttp_versionreasonstatus_codezstatus code must be integer)popset_fields	TypeErrorformat	__class____name__
difference	_defaults__dict__updater   Znormalize_and_validater   r   
isinstancer   intr   	_validate)selfkwargsr   allowedkwargrequiredfield r'   S/var/www/html/magazine_api/magazine_env/lib/python3.10/site-packages/h11/_events.py__init__   s@   



z_EventBundle.__init__c                 C   s   d S Nr'   r!   r'   r'   r(   r    <   s   z_EventBundle._validatec                    s2    j j} fdd jD }d|}d||S )Nc                    s   g | ]}d  | j| qS )z{}={})r   r   ).0r&   r+   r'   r(   
<listcomp>A   s    z)_EventBundle.__repr__.<locals>.<listcomp>z, z{}({}))r   r   r   joinr   )r!   nameZ
kwarg_strsZ	kwarg_strr'   r+   r(   __repr__?   s   

z_EventBundle.__repr__c                 C   s   | j |j ko| j|jkS r*   )r   r   r!   otherr'   r'   r(   __eq__G   s   
z_EventBundle.__eq__c                 C   s   |  | S r*   )r3   r1   r'   r'   r(   __ne__K   s   z_EventBundle.__ne__N)r   
__module____qualname__r   r   r)   r    r0   r3   r4   __hash__r'   r'   r'   r(   r      s    "r   c                   @   s(   e Zd ZdZg dZddiZdd ZdS )r   an  The beginning of an HTTP request.

    Fields:

    .. attribute:: method

       An HTTP method, e.g. ``b"GET"`` or ``b"POST"``. Always a byte
       string. :term:`Bytes-like objects <bytes-like object>` and native
       strings containing only ascii characters will be automatically
       converted to byte strings.

    .. attribute:: target

       The target of an HTTP request, e.g. ``b"/index.html"``, or one of the
       more exotic formats described in `RFC 7320, section 5.3
       <https://tools.ietf.org/html/rfc7230#section-5.3>`_. Always a byte
       string. :term:`Bytes-like objects <bytes-like object>` and native
       strings containing only ascii characters will be automatically
       converted to byte strings.

    .. attribute:: headers

       Request headers, represented as a list of (name, value) pairs. See
       :ref:`the header normalization rules <headers-format>` for details.

    .. attribute:: http_version

       The HTTP protocol version, represented as a byte string like
       ``b"1.1"``. See :ref:`the HTTP version normalization rules
       <http_version-format>` for details.

    )r   r   r   r   r      1.1c                 C   sR   d}| j D ]\}}|dkr|d7 }q| jdkr|dkrtd|dkr'tdd S )N    s   hostr   r8   zMissing mandatory Host: headerzFound multiple Host: headers)r   r   r   )r!   Z
host_countr/   valuer'   r'   r(   r    w   s   zRequest._validateN)r   r5   r6   __doc__r   r   r    r'   r'   r'   r(   r   R   s
    !r   c                   @   s   e Zd Zg dZdddZdS )_ResponseBase)r   r   r   r   r8       )r   r   N)r   r5   r6   r   r   r'   r'   r'   r(   r<      s
    
r<   c                   @      e Zd ZdZdd ZdS )r   a  An HTTP informational response.

    Fields:

    .. attribute:: status_code

       The status code of this response, as an integer. For an
       :class:`InformationalResponse`, this is always in the range [100,
       200).

    .. attribute:: headers

       Request headers, represented as a list of (name, value) pairs. See
       :ref:`the header normalization rules <headers-format>` for
       details.

    .. attribute:: http_version

       The HTTP protocol version, represented as a byte string like
       ``b"1.1"``. See :ref:`the HTTP version normalization rules
       <http_version-format>` for details.

    .. attribute:: reason

       The reason phrase of this response, as a byte string. For example:
       ``b"OK"``, or ``b"Not Found"``.

    c                 C   ,   d| j   krdk sn td| j d S )Nd      zGInformationalResponse status_code should be in range [100, 200), not {}r   r   r   r+   r'   r'   r(   r       s   zInformationalResponse._validateNr   r5   r6   r;   r    r'   r'   r'   r(   r      s    r   c                   @   r>   )r   a  The beginning of an HTTP response.

    Fields:

    .. attribute:: status_code

       The status code of this response, as an integer. For an
       :class:`Response`, this is always in the range [200,
       600).

    .. attribute:: headers

       Request headers, represented as a list of (name, value) pairs. See
       :ref:`the header normalization rules <headers-format>` for details.

    .. attribute:: http_version

       The HTTP protocol version, represented as a byte string like
       ``b"1.1"``. See :ref:`the HTTP version normalization rules
       <http_version-format>` for details.

    .. attribute:: reason

       The reason phrase of this response, as a byte string. For example:
       ``b"OK"``, or ``b"Not Found"``.

    c                 C   r?   )NrA   iX  z:Response status_code should be in range [200, 600), not {}rB   r+   r'   r'   r(   r       s   zResponse._validateNrC   r'   r'   r'   r(   r      s    r   c                   @   s"   e Zd ZdZg dZdddZdS )r   a  Part of an HTTP message body.

    Fields:

    .. attribute:: data

       A :term:`bytes-like object` containing part of a message body. Or, if
       using the ``combine=False`` argument to :meth:`Connection.send`, then
       any object that your socket writing code knows what to do with, and for
       which calling :func:`len` returns the number of bytes that will be
       written -- see :ref:`sendfile` for details.

    .. attribute:: chunk_start

       A marker that indicates whether this data object is from the start of a
       chunked transfer encoding chunk. This field is ignored when when a Data
       event is provided to :meth:`Connection.send`: it is only valid on
       events emitted from :meth:`Connection.next_event`. You probably
       shouldn't use this attribute at all; see
       :ref:`chunk-delimiters-are-bad` for details.

    .. attribute:: chunk_end

       A marker that indicates whether this data object is the last for a
       given chunked transfer encoding chunk. This field is ignored when when
       a Data event is provided to :meth:`Connection.send`: it is only valid
       on events emitted from :meth:`Connection.next_event`. You probably
       shouldn't use this attribute at all; see
       :ref:`chunk-delimiters-are-bad` for details.

    )datachunk_start	chunk_endF)rE   rF   Nr   r5   r6   r;   r   r   r'   r'   r'   r(   r      s    r   c                   @   s   e Zd ZdZdgZdg iZdS )r	   aj  The end of an HTTP message.

    Fields:

    .. attribute:: headers

       Default value: ``[]``

       Any trailing headers attached to this message, represented as a list of
       (name, value) pairs. See :ref:`the header normalization rules
       <headers-format>` for details.

       Must be empty unless ``Transfer-Encoding: chunked`` is in use.

    r   NrG   r'   r'   r'   r(   r	      s    r	   c                   @   s   e Zd ZdZdS )r
   aA  This event indicates that the sender has closed their outgoing
    connection.

    Note that this does not necessarily mean that they can't *receive* further
    data, because TCP connections are composed to two one-way channels which
    can be closed independently. See :ref:`closing` for details.

    No fields.
    N)r   r5   r6   r;   r'   r'   r'   r(   r
     s    	r
   N) r   Z_utilr   r   __all__objectr   r   r<   r   r   r   r	   r
   r'   r'   r'   r(   <module>   s   
<5&#)