
    ")f(.                     p   d dl Z d dlmZ d dlmZmZ d dlmZmZm	Z	m
Z
mZmZ ddlmZmZ ddlmZmZ ddlmZmZmZ g d	Z e j0                   ej2                  d
            Z e j0                   ej2                  d
            Z G d de      Z edd       G d de             Z edd       G d de             Z edd       G d de             Z edd       G d de             Z  edd       G d de             Z! edd       G d de             Z" ed       G d de             Z#y)    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                       e Zd ZdZdZy)r   z$
    Base class for h11 events.
     N)__name__
__module____qualname____doc__	__slots__r       H/var/www/html/flask-app/venv/lib/python3.12/site-packages/h11/_events.pyr   r       s     Ir#   r   FT)initfrozenc                        e Zd ZU dZdZeed<   eed<   eed<   eed<   ddd	deee	f   deee
eeef      e
ee	e	f      f   deee	f   deee	f   d
eddf fdZdZ xZ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   headerstargethttp_versionr   r(   r)   r*      1.1F)r*   _parsedr,   returnNc                   t         	|           t        |t              rt        j                  | d|       n"t        j                  | dt        ||             |sat        j                  | dt        |             t        j                  | dt        |             t        j                  | dt        |             nEt        j                  | d|       t        j                  | d|       t        j                  | d|       d}| j                  D ]  \  }}|dk(  s|dz  } | j                  d	k(  r|dk(  rt        d
      |dkD  rt        d      t        t        | j                  d       t        t        | j                  d       y )Nr(   r,   r   r)   r*   r   s   hostr   r+   zMissing mandatory Host: headerzFound multiple Host: headerszIllegal method characterszIllegal target characters)super__init__
isinstancer   object__setattr__r   r   r(   r*   r   r   	method_rer   request_target_rer)   )
selfr   r(   r)   r*   r,   
host_countnamevalue	__class__s
            r$   r1   zRequest.__init__R   sO    	gw'tY8i!7!Q tXx/?@tXx/?@t^Xl5KLtXv6tXv6t^\B 
<< 	 KD%wa
	  &:?$%EFF>$%CDDDKK)DE"DKK1LMr#   )r   r   r    r!   r"   bytes__annotations__r   r   strr	   r
   boolr1   __hash____classcell__r;   s   @r$   r   r   (   s    B @IMM +1(N eSj!(N wU5%<%8 94c3h;PPQ	(N
 eSj!(N E3J'(N (N 
(NV Hr#   r   c                        e Zd ZU dZeed<   eed<   eed<   eed<   dddd	deee	e
eef      e	e
eef      f   dedeeef   deeef   d
eddf fdZddZdZ xZS )_ResponseBase)r(   r*   reasonstatus_coder(   r*   rE   rF   r+   r#   F)r*   rE   r,   r,   r-   Nc                \   t         |           t        |t              rt        j                  | d|       n"t        j                  | dt        ||             |s|t        j                  | dt        |             t        j                  | dt        |             t        |t              st        d      t        j                  | dt        |             nEt        j                  | d|       t        j                  | d|       t        j                  | d|       | j                          y )Nr(   r/   rE   r*   zstatus code must be integerrF   )r0   r1   r2   r   r3   r4   r   r   intr   __post_init__)r7   r(   rF   r*   rE   r,   r;   s         r$   r1   z_ResponseBase.__init__   s     	gw'tY8i!7!Q tXx/?@t^Xl5KLk3/()FGG t]C4DEtXv6t^\Bt]K@r#   c                      y )Nr   r7   s    r$   rI   z_ResponseBase.__post_init__   s    r#   r-   N)r   r   r    r"   r   r=   r<   rH   r   r	   r
   r>   r?   r1   rI   r@   rA   rB   s   @r$   rD   rD      s    DIM +1$' wU5%<%8 94c3h;PPQ 	
 E3J' eSj!  
> Hr#   rD   c                       e Zd ZdZddZdZy)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"``.

    Nc                 z    d| j                   cxk  rdk  s&n t        dj                  | j                               y )Nd      zGInformationalResponse status_code should be in range [100, 200), not {}rF   r   formatrK   s    r$   rI   z#InformationalResponse.__post_init__   s<    t''-#-$%%+VD,<,<%=  .r#   rL   r   r   r    r!   rI   r@   r   r#   r$   r   r      s    : Hr#   r   c                       e Zd ZdZddZdZy)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,
       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"``.

    Nc                 z    d| j                   cxk  rdk  s&n t        dj                  | j                               y )NrP   i  z;Response status_code should be in range [200, 1000), not {}rQ   rK   s    r$   rI   zResponse.__post_init__   s>    t''.$.$MTT$$  /r#   rL   rS   r   r#   r$   r   r      s    8 Hr#   r   c            	       T    e Zd ZU dZdZeed<   eed<   eed<   	 d	dedededdfdZdZ	y)
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_endrW   rX   rY   r-   Nc                     t         j                  | d|       t         j                  | d|       t         j                  | d|       y )NrW   rX   rY   )r3   r4   )r7   rW   rX   rY   s       r$   r1   zData.__init__+  s:     	4.4<4i8r#   )FF)
r   r   r    r!   r"   r<   r=   r?   r1   r@   r   r#   r$   r   r     sR    @ 5I
KO IN99(,9AE9	9 Hr#   r   c            	       z     e Zd ZU dZdZeed<   ddddeeee	e
e
f      ee	eef      df   deddf fd	ZdZ xZ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(   r(   NF)r(   r,   r,   r-   c                    t         |           |t        g       }nt        |t              st	        ||      }t
        j                  | d|       y )Nr/   r(   )r0   r1   r   r2   r   r3   r4   )r7   r(   r,   r;   s      r$   r1   zEndOfMessage.__init__Q  sF     	?bkGGW-,WgFG4G4r#   )r   r   r    r!   r"   r   r=   r   r	   r
   r<   r>   r?   r1   r@   rA   rB   s   @r$   r   r   ;  ss      I 5 T%u-.U38_0EtK
5 5 
5" Hr#   r   )r&   c                       e Zd ZdZy)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    r!   r   r#   r$   r   r   e  s     	r#   r   )$reabcr   dataclassesr   r   typingr   r   r   r	   r
   r   _abnfr   r   _headersr   r   _utilr   r   r   __all__compileencoder5   r6   r   r   rD   r   r   r   r   r   r   r#   r$   <module>rh      sf   
  ( 6 6 ) 5 9 9 BJJ}v}}W-.	BJJ4~44W=> C  d#Te T $Tn d#+E + $+\ d#&M & $&R d#&} & $&R d#/5 / $/n d#&5 & $&R $	u 	 	r#   