HEX
Server: Apache/2.4.52 (Ubuntu)
System: Linux spn-python 5.15.0-89-generic #99-Ubuntu SMP Mon Oct 30 20:42:41 UTC 2023 x86_64
User: arjun (1000)
PHP: 8.1.2-1ubuntu2.20
Disabled: NONE
Upload Files
File: //usr/local/lib/python3.10/dist-packages/h11/__pycache__/_events.cpython-310.pyc
o

���g(.�@svddlZddlmZddlmZmZddlmZmZm	Z	m
Z
mZmZddl
mZmZddlmZmZddlmZmZmZgd	�Ze�e�d
��Ze�e�d
��ZGdd�de�Zed
dd�Gdd�de��Zed
dd�Gdd�de��Zed
dd�Gdd�de��Zed
dd�Gdd�de��Z ed
dd�Gdd�de��Z!ed
dd�Gdd�de��Z"edd�Gdd�de��Z#dS)�N)�ABC)�	dataclass�field)�Any�cast�Dict�List�Tuple�Union�)�method�request_target)�Headers�normalize_and_validate)�bytesify�LocalProtocolError�validate)�Event�Request�InformationalResponse�Response�Data�EndOfMessage�ConnectionClosed�asciic@seZdZdZdZdS)rz$
    Base class for h11 events.
    �N)�__name__�
__module__�__qualname__�__doc__�	__slots__rrr�6/usr/local/lib/python3.10/dist-packages/h11/_events.pyr srFT)�init�frozenc
s�eZdZUdZdZeed<eed<eed<eed<ddd	�deee	fdeee
eeefe
ee	e	ffdeee	fdeee	fd
eddf�fd
d�Z
dZ�ZS)ranThe 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�headers�target�http_versionrr$r%r&�1.1F)r&�_parsedr(�returnNc	st���t|t�rt�|d|�nt�|dt||d��|s;t�|dt|��t�|dt|��t�|dt|��nt�|d|�t�|d|�t�|d|�d}|jD]\}}|dkra|d7}qU|j	d	kro|dkrot
d
��|dkrwt
d��tt|j
d�tt|jd
�dS)Nr$�r(rr%r&rshostrr'zMissing mandatory Host: headerzFound multiple Host: headerszIllegal method characterszIllegal target characters)�super�__init__�
isinstancer�object�__setattr__rrr$r&rr�	method_rer�request_target_rer%)	�selfrr$r%r&r(�
host_count�name�value��	__class__rr!r,Rs0
	
��zRequest.__init__)rrrrr �bytes�__annotations__rr
�strrr	�boolr,�__hash__�
__classcell__rrr6r!r(s.
!�
�$�
�
���+rc
s�eZdZUdZeed<eed<eed<eed<dddd	�deee	e
eefe	e
eeffdedeeefdeeefd
eddf�fd
d�Z
ddd�ZdZ�ZS)�
_ResponseBase)r$r&�reason�status_coder$r&r?r@r'�F)r&r?r(r(r)Ncs�t���t|t�rt�|d|�nt�|dt||d��|sDt�|dt|��t�|dt|��t|t�s:t	d��t�|dt|��nt�|d|�t�|d|�t�|d|�|�
�dS)Nr$r*r?r&zstatus code must be integerr@)r+r,r-rr.r/rr�intr�
__post_init__)r2r$r@r&r?r(r6rr!r,�s 
	
�
z_ResponseBase.__init__cCsdS)Nr�r2rrr!rC�sz_ResponseBase.__post_init__�r)N)rrrr rr9r8rBr
rr	r:r;r,rCr<r=rrr6r!r>�s0
�$��
�
���
r>c@�eZdZdZddd�ZdZdS)raAn 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"``.

    r)NcC�,d|jkrdksntd�|j���dS)N�d��zGInformationalResponse status_code should be in range [100, 200), not {}�r@r�formatrDrrr!rC�s��z#InformationalResponse.__post_init__rE�rrrrrCr<rrrr!r�s
rc@rF)ra�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,
       1000).

    .. 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"``.

    r)NcCrG)NrIi�z;Response status_code should be in range [200, 1000), not {}rJrDrrr!rC�s���zResponse.__post_init__rErLrrrr!r�s
	rc	@sPeZdZUdZdZeed<eed<eed<	ddedededdfd	d
�ZdZ	dS)raPart 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_endrMrNrOFr)NcCs.t�|d|�t�|d|�t�|d|�dS)NrMrNrO)r.r/)r2rMrNrOrrr!r,+sz
Data.__init__)FF)
rrrrr r8r9r;r,r<rrrr!rs"
 ����
�rc	sleZdZUdZdZeed<ddd�deeee	e
e
fee	eefdfdeddf�fd	d
�Z
dZ�ZS)rajThe 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$r$NF)r$r(r(r)csDt���|durtg�}nt|t�st||d�}t�|d|�dS)Nr*r$)r+r,rr-rr.r/)r2r$r(r6rr!r,Qs


zEndOfMessage.__init__)rrrrr rr9r
rr	r8r:r;r,r<r=rrr6r!r;s 
�"����r)r#c@seZdZdZdS)raAThis 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)rrrrrrrr!res
r)$�re�abcr�dataclassesrr�typingrrrrr	r
�_abnfrr
�_headersrr�_utilrrr�__all__�compile�encoder0r1rrr>rrrrrrrrr!�<module>s2 


W
.
)
)
7)