L i.`ddlZddlmZddlmZddlmZmZmZddl m Z m Z ddl m Z mZddlmZmZmZgd Zej(e j*d Zej(e j*d ZGd d eZed dGddeZed dGddeZed dGddeZed dGddeZed dGddeZed dGddeZedGddeZy)N)ABC) dataclass)ListTupleUnion)methodrequest_target)Headersnormalize_and_validate)bytesifyLocalProtocolErrorvalidate)EventRequestInformationalResponseResponseData EndOfMessageConnectionClosedasciiceZdZdZdZy)rz$ Base class for h11 events. N)__name__ __module__ __qualname____doc__ __slots__rQ/mnt/ssd/data/python-lab/Trading/venv/lib/python3.12/site-packages/h11/_events.pyrr sIrrFT)initfrozenc eZdZUdZdZeed<eed<eed<eed<ddd deee fdeee e eefe e e e ffdeee fdeee fd e d d f fd Z d ZxZS)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 ` 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 `_. Always a byte string. :term:`Bytes-like objects ` 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 ` 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 ` for details. )r headerstarget http_versionr r$r%r&1.1F)r&_parsedr(returnNct |t|trtj |d|n"tj |dt |||satj |dt|tj |dt|tj |dt|nEtj |d|tj |d|tj |d|d}|jD]\}}|dk(s |dz }|jd k(r|dk(r td |dkDr td tt|jd tt|jd y)Nr$r(r r%r&rshostrr'zMissing mandatory Host: headerzFound multiple Host: headerszIllegal method characterszIllegal target characters)super__init__ isinstancer object __setattr__r r r$r&rr method_rer request_target_rer%) selfr r$r%r&r( host_countnamevalue __class__s r r-zRequest.__init__RsO  gw '   tY 8   i!7!Q    tXx/? @   tXx/? @   t^Xl5K L   tXv 6   tXv 6   t^\ B << KD%wa      &:?$%EF F >$%CD DDKK)DE"DKK1LMr)rrrrrbytes__annotations__r rstrrrboolr-__hash__ __classcell__r7s@r rr(sB@I M  M+1(NeSj!(NwU5%<%8 94c3h;PPQ (N eSj! (N E3J' (N(N (NVHrrc eZdZUdZeed<eed<eed<eed<dddd deee e eefe e e e ffdedeee fdeee fd e d d f fd Z ddZd ZxZS) _ResponseBase)r$r&reason status_coder$r&rArBr'rF)r&rAr(r(r)Nc\t|t|trtj |d|n"tj |dt |||s|tj |dt|tj |dt|t|ts tdtj |dt|nEtj |d|tj |d|tj |d||jy)Nr$r+rAr&zstatus code must be integerrB) r,r-r.r r/r0r r intr __post_init__)r3r$rBr&rAr(r7s r r-z_ResponseBase.__init__s  gw '   tY 8   i!7!Q    tXx/? @   t^Xl5K Lk3/()FGG   t]C 4D E   tXv 6   t^\ B   t]K @ rcy)Nrr3s r rEz_ResponseBase.__post_init__s rr)N)rrrrr r9r8rDrrrr:r;r-rEr<r=r>s@r r@r@sDI  M+1$'wU5%<%8 94c3h;PPQ  E3J'  eSj!  > Hrr@ceZdZdZddZdZy)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 ` 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 ` for details. .. attribute:: reason The reason phrase of this response, as a byte string. For example: ``b"OK"``, or ``b"Not Found"``. Nczd|jcxkrdks&ntdj|jy)NdzGInformationalResponse status_code should be in range [100, 200), not {}rBrformatrGs r rEz#InformationalResponse.__post_init__s<t''-#-$%%+VD,<,<%= .rrHrrrrrEr<rrr rrs:HrrceZdZdZddZdZy)raThe 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 ` 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 ` for details. .. attribute:: reason The reason phrase of this response, as a byte string. For example: ``b"OK"``, or ``b"Not Found"``. Nczd|jcxkrdks&ntdj|jy)NrLiz;Response status_code should be in range [200, 1000), not {}rMrGs r rEzResponse.__post_init__s>t''.$.$MTT$$ /rrHrOrrr rrs8Hrrc TeZdZUdZdZeed<eed<eed< d dedededdfdZdZ y) 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_endrSrTrUr)Nctj|d|tj|d|tj|d|y)NrSrTrU)r/r0)r3rSrTrUs r r-z Data.__init__+s: 4.4 <4i8r)FF) rrrrrr8r9r;r-r<rrr rrsR@5I KOIN99(,9AE9 9Hrrc zeZdZUdZdZeed<ddddeeee e e fee e e fdfde ddffd Z dZxZS) 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 ` for details. Must be empty unless ``Transfer-Encoding: chunked`` is in use. )r$r$NF)r$r(r(r)ct|| tg}nt|ts t ||}t j |d|y)Nr+r$)r,r-r r.r r/r0)r3r$r(r7s r r-zEndOfMessage.__init__QsF  ?bkGGW-,WgFG4G4r)rrrrrr r9rrrr8r:r;r-r<r=r>s@r rr;ss I   5 T%u -.U38_0Et K 5  5 5"Hrr)r"ceZdZdZy)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)rrrrrrr rres  rr) reabcr dataclassesrtypingrrr_abnfr r _headersr r _utilr rr__all__compileencoder1r2rrr@rrrrrrrr rdsf !%%)599  BJJ}v}}W- . BJJ4~44W=>C d#TeT$Tn d#+E+$+\ d#&M&$&R d#&}&$&R d#/5/$/n d#&5&$&R $  u    r