
     f(.                        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 j         ej        d
                    Z e j         ej        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#dS )    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dS )r   z$
    Base class for h11 events.
     N)__name__
__module____qualname____doc__	__slots__r       N/var/www/api.educacionweb.es/myenv/lib/python3.11/site-packages/h11/_events.pyr   r       s          IIIr#   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                              | d|           n+t                              | dt          ||                     |s|t                              | dt          |                     t                              | dt          |                     t                              | dt          |                     nTt                              | d|           t                              | d|           t                              | d|           d}| j        D ]\  }}|dk    r|dz  }| j	        d	k    r|dk    rt          d
          |dk    rt          d          t          t          | j        d           t          t          | j        d           d S )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   s    	gw'' 	tY8888i!7!Q!Q!Q    	CtXx/?/?@@@tXx/?/?@@@t^Xl5K5KLLLLtXv666tXv666t^\BBB 
< 	  	 KD%wa
&&:??$%EFFF>>$%CDDDDK)DEEE"DK1LMMMMMr#   )r   r   r    r!   r"   bytes__annotations__r   r   strr	   r
   boolr1   __hash____classcell__r;   s   @r$   r   r   (   s         B @IMMMMMM +1(N (N (N eSj!(N wU5%<%8 94c3h;PPQ	(N
 eSj!(N E3J'(N (N 
(N (N (N (N (N (NV HHHHHr#   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                              | d|           n+t                              | dt          ||                     |st                              | dt          |                     t                              | dt          |                     t          |t                    st          d          t                              | dt          |                     nTt                              | d|           t                              | d|           t                              | d|           | 
                                 d S )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__   sg    	gw'' 	tY8888i!7!Q!Q!Q    	AtXx/?/?@@@t^Xl5K5KLLLk3// H()FGGG t]C4D4DEEEEtXv666t^\BBBt]K@@@r#   c                     d S )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MMM +1$'   wU5%<%8 94c3h;PPQ 	
 E3J' eSj!  
     >    HHHHHr#   rD   c                       e Zd ZdZddZ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"``.

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

    r-   Nc                 |    d| j         cxk    rdk     s)n t          d                    | j                             d S )NrP   i  z;Response status_code should be in range [200, 1000), not {}rQ   rK   s    r$   rI   zResponse.__post_init__   sW    t'....$....$MTT$    /.r#   rL   rS   r   r#   r$   r   r      s3         8    HHHr#   r   c            	       V    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	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_endrW   rX   rY   Fr-   Nc                     t                               | d|           t                               | d|           t                               | d|           d S )NrW   rX   rY   )r3   r4   )r7   rW   rX   rY   s       r$   r1   zData.__init__+  sR     	4...4<<<4i88888r#   )FF)
r   r   r    r!   r"   r<   r=   r?   r1   r@   r   r#   r$   r   r     s          @ 5I
KKKOOO IN9 99(,9AE9	9 9 9 9 HHHr#   r   c            	            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
                              | d|           d S )Nr/   r(   )r0   r1   r   r2   r   r3   r4   )r7   r(   r,   r;   s      r$   r1   zEndOfMessage.__init__Q  sp     	?bkkGGGW-- 	G,WgFFFG4G44444r#   )r   r   r    r!   r"   r   r=   r   r	   r
   r<   r>   r?   r1   r@   rA   rB   s   @r$   r   r   ;  s            I 5 5 5 T%u-.U38_0EtK
5 5 
5 5 5 5 5 5" HHHHHr#   r   )r&   c                       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    r!   r   r#   r$   r   r   e  s          	Dr#   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      s2   
			       ( ( ( ( ( ( ( ( 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 ) ) ) ) ) ) ) ) 5 5 5 5 5 5 5 5 9 9 9 9 9 9 9 9 9 9   BJ}v}W--..	BJ4~4W==>>     C    d###T T T T Te T T $#Tn d###+ + + + +E + + $#+\ d###& & & & &M & & $#&R d###& & & & &} & & $#&R d###/ / / / /5 / / $#/n d###& & & & &5 & & $#&R $	 	 	 	 	u 	 	 	 	 	r#   