o
    Dh&                     @   s   d dl Z ddlmZ ddlmZ ddlmZmZmZ g dZ	e 
e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 )    N   )_headers)request_target)bytesifyLocalProtocolErrorvalidate)RequestInformationalResponseResponseDataEndOfMessageConnectionClosedasciic                   @   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| _|s}dD ]}|| j	v rgt| j	| | j	|< qVd| j	v r}t| jtswtd	t| j| _|   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   normalize_and_validater   r   
isinstancer   intr   	_validate)selfkwargsr   allowedkwargrequiredfield r,   F/var/www/html/env_mimamsha/lib/python3.10/site-packages/h11/_events.py__init__   sF   



z_EventBundle.__init__c                 C   s   d S Nr,   r&   r,   r,   r-   r%   I   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+   r0   r,   r-   
<listcomp>N   s    z)_EventBundle.__repr__.<locals>.<listcomp>z, z{}({}))r   r   r   joinr   )r&   name
kwarg_strs	kwarg_strr,   r0   r-   __repr__L   s   

z_EventBundle.__repr__c                 C   s   | j |j ko| j|jkS r/   )r   r    r&   otherr,   r,   r-   __eq__U   s   z_EventBundle.__eq__c                 C   s   |  | S r/   )r:   r8   r,   r,   r-   __ne__X   s   z_EventBundle.__ne__N)r   
__module____qualname__r   r   r.   r%   r7   r:   r;   __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   s`   d}| j D ]\}}|dkr|d7 }q| jdkr|dkrtd|dkr'tdtt| jd d S )Nr   s   hostr   r?   zMissing mandatory Host: headerzFound multiple Host: headerszIllegal target characters)r   r   r   r   request_target_rer   )r&   
host_countr4   valuer,   r,   r-   r%      s   zRequest._validateN)r   r<   r=   __doc__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   r?       )r   r   N)r   r<   r=   r   r   r,   r,   r,   r-   rD      s    rD   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   r0   r,   r,   r-   r%      s   zInformationalResponse._validateNr   r<   r=   rC   r%   r,   r,   r,   r-   r	      s    r	   c                   @   rF   )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   rG   )NrI   iX  z:Response status_code should be in range [200, 600), not {}rJ   r0   r,   r,   r-   r%      s   zResponse._validateNrK   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)rM   rN   Nr   r<   r=   rC   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   NrO   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   r<   r=   rC   r,   r,   r,   r-   r   &  s    
r   )re r   _abnfr   _utilr   r   r   __all__compileencoder@   objectr   r   rD   r	   r
   r   r   r   r,   r,   r,   r-   <module>   s   	D7&&*