Ë
    ×Õ°jž  ã                   ón   — d Z ddlmZ ddlmZmZ ddlmZ ddlm	Z	  G d„ d«      Z
 G d„ d	e«      Zd	dgZy
)zV
HTTP/2 request wrapper.

Provides a Request-compatible interface for HTTP/2 streams.
é    )ÚBytesIO)ÚHeaderPolicyÚ!RFC9110_5_5_INVALID_AND_DANGEROUS)ÚInvalidHeader)Úsplit_request_uric                   ó@   — e Zd ZdZd„ Zd
d„Zd
d„Zd
d„Zd„ Zd„ Z	d	„ Z
y)Ú	HTTP2Bodyz›Body wrapper for HTTP/2 request data.

    Provides a file-like interface to the request body,
    compatible with gunicorn's Body class expectations.
    c                 óD   — t        |«      | _        t        |«      | _        y)zfInitialize with body data.

        Args:
            data: bytes containing the request body
        N)r   Ú_dataÚlenÚ_len)ÚselfÚdatas     úL/var/www/mission/venv/lib/python3.12/site-packages/gunicorn/http2/request.pyÚ__init__zHTTP2Body.__init__   s   € ô ˜T“]ˆŒ
Ü˜“Iˆ�	ó    Nc                 óp   — |€| j                   j                  «       S | j                   j                  |«      S )z­Read data from the body.

        Args:
            size: Number of bytes to read, or None for all remaining

        Returns:
            bytes: The requested data
        )r   Úread©r   Úsizes     r   r   zHTTP2Body.read&   s-   € ð ˆ<Ø—:‘:—?‘?Ó$Ð$Ø�z‰z�‰˜tÓ$Ð$r   c                 óp   — |€| j                   j                  «       S | j                   j                  |«      S )zŽRead a line from the body.

        Args:
            size: Maximum bytes to read

        Returns:
            bytes: A line of data
        )r   Úreadliner   s     r   r   zHTTP2Body.readline3   s1   € ð ˆ<Ø—:‘:×&Ñ&Ó(Ð(Ø�z‰z×"Ñ" 4Ó(Ð(r   c                 ó8   — | j                   j                  |«      S )z•Read all lines from the body.

        Args:
            hint: Approximate byte count hint

        Returns:
            list: List of lines
        )r   Ú	readlines)r   Úhints     r   r   zHTTP2Body.readlines@   s   € ð �z‰z×#Ñ# DÓ)Ð)r   c                 ó,   — t        | j                  «      S )zIterate over lines in the body.)Úiterr   ©r   s    r   Ú__iter__zHTTP2Body.__iter__K   s   € ä�D—J‘JÓÐr   c                 ó   — | j                   S )zReturn the content length.)r   r   s    r   Ú__len__zHTTP2Body.__len__O   s   € à�y‰yÐr   c                 ó8   — | j                   j                  «        y)zClose the body stream.N)r   Úcloser   s    r   r#   zHTTP2Body.closeS   s   € à�
‰
×ÑÕr   )N)Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   r   r   r   r   r!   r#   © r   r   r	   r	      s*   „ ñòó%ó)ó	*ò òór   r	   c                   óR   — e Zd ZdZdZd„ Zd„ Zd„ Zd„ Ze	d„ «       Z
e	d„ «       Zd	„ Zy
)ÚHTTP2RequestzìHTTP/2 request wrapper compatible with gunicorn Request interface.

    Wraps an HTTP2Stream to provide the same interface as the HTTP/1.x
    Request class, allowing workers to handle HTTP/2 requests using
    existing code paths.
    Fc           	      ó°  — || _         || _        || _        || _        d| _        |j                  «       }|j                  dd«      | _        |j                  rdnd| _	        |j                  d«      }|r| j                  «       r|| _	        |j                  dd«      }|j                  d	d
«      }|| _        	 t        |«      }|j                  xs d| _        |j                  xs d| _        |j                  xs d| _        || _        g | _        dg}	t'        «       }
| j)                  «       \  }}|j+                  «       D ]k  \  }}|j-                  «       }t/        j0                  |«      rt3        || ¬«      ‚| j5                  |||	|
||«      }|€ŒQ| j$                  j7                  |«       Œm |rI| j$                  D ��cg c]  \  }}|dk7  sŒ||f‘Œ c}}| _        | j$                  j7                  d|f«       g | _        |j8                  r4|j8                  D ��cg c]  \  }}|j-                  «       |f‘Œ c}}| _        |j;                  «       }t=        |«      | _        d| _         d| _!        |jD                  | _#        d| _$        |jJ                  | _%        |jL                  | _&        y# t         $ r || _        d| _        d| _        Y �ŒÈw xY wc c}}w c c}}w )zåInitialize from an HTTP/2 stream.

        Args:
            stream: HTTP2Stream instance with received headers/body
            cfg: Gunicorn configuration object
            peer_addr: Client address tuple (host, port)
        )é   r   z:methodÚGETÚhttpsÚhttpz:schemez
:authorityÚ z:pathú/F)ÚreqNÚHOST)'ÚstreamÚcfgÚ	peer_addrÚremote_addrÚversionÚget_pseudo_headersÚgetÚmethodÚis_sslÚschemeÚ_peer_is_trusted_proxyÚurir   ÚpathÚqueryÚfragmentÚ
ValueErrorÚ
_authorityÚheadersÚsetÚ_peer_trusted_for_forwardedÚget_regular_headersÚupperr   Úsearchr   Ú_apply_header_policyÚappendÚtrailersÚget_request_bodyr	   ÚbodyÚ
must_closeÚ_expected_100_continueÚ	stream_idÚ
req_numberÚproxy_protocol_infoÚpriority_weightÚpriority_depends_on)r   r4   r5   r6   ÚpseudoÚclaimed_schemeÚ	authorityr@   ÚpartsÚscheme_stateÚseenÚsecure_scheme_headersÚforwarder_headersÚnameÚvalueÚkeptÚnÚvÚ	body_datas                      r   r   zHTTP2Request.__init__d   s³  € ð ˆŒØˆŒØ"ˆŒØ$ˆÔð ˆŒð ×*Ñ*Ó,ˆØ—j‘j ¨EÓ2ˆŒð
 "%§¢‘g°ˆŒØŸ™ IÓ.ˆÙ˜d×9Ñ9Ô;Ø(ˆDŒKØ—J‘J˜|¨RÓ0ˆ	Ø�z‰z˜' 3Ó'ˆð ˆŒð	Ü% dÓ+ˆEØŸ
™
Ò( bˆDŒIØŸ™Ò*¨ˆDŒJØ!ŸN™NÒ0¨bˆDŒMð $ˆŒð
 ˆŒØ�wˆÜ‹uˆà×,Ñ,Ó.ñ 	1ÐÐ0à!×5Ñ5Ó7ò 	&‰KˆD�%à—:‘:“<ˆDÜ0×7Ñ7¸Ô>Ü# D¨dÔ3Ð3Ø×,Ñ,Ø�e˜\¨4Ø%Ð'8óˆDð ˆ|ØØ�L‰L×Ñ Õ%ð	&ñ  Ø/3¯|©|×K¡t q¨!¸qÀF»{˜Q šFÓKˆDŒLØ�L‰L×Ñ ¨Ð 3Ô4ð ˆŒØ�?Š?ð $*§?¡?÷á�D˜%ð —‘“˜uÒ%óˆDŒMð ×+Ñ+Ó-ˆ	Ü˜iÓ(ˆŒ	ð  ˆŒð ',ˆÔ#ð !×*Ñ*ˆŒð $(ˆÔ ð  &×5Ñ5ˆÔØ#)×#=Ñ#=ˆÕ øô} ò 	ØˆDŒIØˆDŒJØˆD�Mð	üóB Lùós%   Â6A
J' Æ=KÇKÈKÊ'K	ËK	c                 ó   — d| _         y)z1Force the connection to close after this request.TN©rP   r   s    r   Úforce_closezHTTP2Request.force_closeÉ   s	   € àˆ�r   c                 ó   — | j                   ryy)z÷Check if connection should close after this request.

        HTTP/2 connections are persistent by design, but we may still
        need to close if explicitly requested.

        Returns:
            bool: True if connection should close
        TFrf   r   s    r   Úshould_closezHTTP2Request.should_closeÍ   s   € ð �?Š?Øàr   c                 ó^   — |j                  «       }| j                  D ]  \  }}||k(  sŒ|c S  y)zªGet a header value by name.

        Args:
            name: Header name (case-insensitive)

        Returns:
            str: Header value, or None if not found
        N)rI   rE   )r   r_   Úh_nameÚh_values       r   Ú
get_headerzHTTP2Request.get_headerÛ   s7   € ð �z‰z‹|ˆØ#Ÿ|™|ò 	‰OˆF�GØ˜‹~Ø’ð	ð r   c                 ó`   — | j                  d«      }|�	 t        |«      S y# t        $ r Y yw xY w)zsGet the Content-Length header value.

        Returns:
            int: Content length, or None if not set
        zCONTENT-LENGTHN)rm   ÚintrC   )r   Úcls     r   Úcontent_lengthzHTTP2Request.content_lengthê   sB   € ð �_‰_Ð-Ó.ˆØˆ>ðÜ˜2“w�ð øô ò ØØðús   •
! ¡	-¬-c                 ó$   — | j                  d«      S )zoGet the Content-Type header value.

        Returns:
            str: Content type, or None if not set
        zCONTENT-TYPE)rm   r   s    r   Úcontent_typezHTTP2Request.content_typeù   s   € ð �‰˜~Ó.Ð.r   c                 ój   — d| j                   › d| j                  › d| j                  j                  › d�S )Nz<HTTP2Request method=z path=z stream_id=ú>)r;   r@   r4   rR   r   s    r   Ú__repr__zHTTP2Request.__repr__  s?   € ðØ—k‘k�]ð #Ø—I‘I�;ð ØŸ™×.Ñ.Ð/¨qð2ð	
r   N)r$   r%   r&   r'   Ú_policy_expect_continuer   rg   ri   rm   Úpropertyrq   rs   rv   r(   r   r   r*   r*   X   sR   „ ñð $Ðòc>òJòòð ñó ðð ñ/ó ð/ó
r   r*   N)r'   Úior   Úgunicorn.http.messager   r   Úgunicorn.http.errorsr   Úgunicorn.utilr   r	   r*   Ú__all__r(   r   r   ú<module>r~      sB   ðñõ ÷õ /Ý +÷?ñ ?ôDp
�<ô p
ðf ˜;Ð
'�r   