+
    j                     B    ^ RI HtHt ^ RIHtHtHt Rt ! R R4      tR# )    )LengthReaderBody)InvalidUWSGIHeaderUnsupportedModifierForbiddenUWSGIRequesti  c                   ^   a  ] tR t^t o RtRR ltR tR tR tR t	R t
R tR	 tR
 tRtV tR# )UWSGIRequesta  uWSGI protocol request parser.

The uWSGI protocol uses a 4-byte binary header:
- Byte 0: modifier1 (packet type, 0 = WSGI request)
- Bytes 1-2: datasize (16-bit little-endian, size of vars block)
- Byte 3: modifier2 (additional flags, typically 0)

After the header:
1. Vars block (datasize bytes): Key-value pairs containing WSGI environ
   - Each pair: 2-byte key_size (LE) + key + 2-byte val_size (LE) + value
2. Request body (determined by CONTENT_LENGTH in vars)
c                   Wn         W n        W0n        W0n        W@n        R V n        R V n        R V n        R V n        RV n	        RV n
        . V n        . V n        R V n        VP                  '       d   RMRV n        RV n        / V n        ^ V n        ^ V n        R V n        RV n        V P-                  4        V P/                  V P                  4      pV P                  P1                  V4       V P3                  4        R # )N httpshttpF)   r   )cfgunreader	peer_addrremote_addr
req_numbermethoduripathqueryfragmentversionheaderstrailersbodyis_sslscheme
must_close
uwsgi_vars	modifier1	modifier2proxy_protocol_info_expected_100_continue_check_allowed_ipparseunreadset_body_reader)selfr   r   r   r   unuseds   &&&&& K/var/www/idalgo/venv/lib/python3.14/site-packages/gunicorn/uwsgi/message.py__init__UWSGIRequest.__init__   s     "$$ 	
	!$g  $(  ',# 	  DMM*V$    c                    \        V P                  RRR.4      p\        V P                  \        4      '       g   R# RV9   d   R# V P                  ^ ,          V9  d   \        V P                  ^ ,          4      hR# )z(Verify source IP is in the allowed list.uwsgi_allow_ipsz	127.0.0.1z::1N*)getattrr   
isinstancer   tupler   )r)   	allow_ipss   & r+   r%   UWSGIRequest._check_allowed_ipF   sg    DHH&7+u9MN	 $..%00 )>>!I-'q(9:: .r.   c                    RV n         R# )z1Force the connection to close after this request.TN)r   )r)   s   &r+   force_closeUWSGIRequest.force_closeU   s	    r.   c                   V P                  V^4      p\        V4      ^8  d   \        R4      hV^ ,          V n        \        P                  VR,          R4      pV^,          V n        V P                  ^ 8w  d   \        V P                  4      hV^ 8  d>   V P                  W4      p\        V4      V8  d   \        R4      hV P                  V4       V P                  4        R# )z)Parse uWSGI packet header and vars block.zincomplete header:r      Nlittlezincomplete vars blockr.   )
_read_exactlenr   r!   int
from_bytesr"   r   _parse_vars_extract_request_info)r)   r   headerdatasize	vars_datas   &&   r+   r&   UWSGIRequest.parseY   s     !!(A.v;?$%899>>&+x8 >>Q%dnn55 a<((<I9~(()@AAY' 	""$r.   c                $    VP                  V4      # )z*Read exactly size bytes from the unreader.)read)r)   r   sizes   &&&r+   r=   UWSGIRequest._read_exactt   s    }}T""r.   c                   ^ p^ pV\        V4      8  EdI   V\        8  d   \        R4      hV^,           \        V4      8  d   \        R4      h\        P	                  WV^,            R4      pV^,          pW$,           \        V4      8  d   \        R4      hWW$,            P                  R4      pW$,          pV^,           \        V4      8  d   \        R4      h\        P	                  WV^,            R4      pV^,          pW&,           \        V4      8  d   \        R4      hWW&,            P                  R4      pW&,          pWpP                  V&   V^,          pEKY  R# )	zrParse uWSGI vars block into key-value pairs.

Format: key_size (2 bytes LE) + key + val_size (2 bytes LE) + value
ztoo many variablesztruncated key sizer<   ztruncated keyzlatin-1ztruncated value sizeztruncated valueN)r>   MAX_UWSGI_VARSr   r?   r@   decoder    )r)   datapos	var_countkey_sizekeyval_sizevalues   &&      r+   rA   UWSGIRequest._parse_varsx   s:   
 	CIoN*()=>> QwT"()=>>~~dsQw&7BH1HC ~D	)(993>*11)<COC QwT"()?@@~~dsQw&7BH1HC ~D	)():;;S^,33I>EOC#(OOC NI; r.   c                   V P                   P                  RR4      V n        V P                   P                  RR4      V n        V P                   P                  RR4      V n        V P                  '       d$   V P                  : RV P                  : 2V n        MV P                  V n        V P                   P                  RR4      P                  4       R9   d	   R	V n        M)R
V P                   9   d   V P                   R
,          V n        V P                   P                  4        F  w  rVP                  R4      '       d8   VR,          P                  RR4      pV P                  P                  W234       KS  VR8X  d    V P                  P                  RV34       Ky  VR8X  g   K  V P                  P                  RV34       K  	  R# )a  Extract HTTP request info from uWSGI vars.

Header Mapping (CGI/WSGI to HTTP):

The uWSGI protocol passes HTTP headers using CGI-style environment
variable naming. This method converts them back to HTTP header format:

- HTTP_* vars: Strip 'HTTP_' prefix, replace '_' with '-'
  Example: HTTP_X_FORWARDED_FOR -> X-FORWARDED-FOR
  Example: HTTP_ACCEPT_ENCODING -> ACCEPT-ENCODING

- CONTENT_TYPE: Mapped directly to CONTENT-TYPE header
  (CGI spec excludes HTTP_ prefix for this header)

- CONTENT_LENGTH: Mapped directly to CONTENT-LENGTH header
  (CGI spec excludes HTTP_ prefix for this header)

Note: The underscore-to-hyphen conversion is lossy. Headers that
originally contained underscores (e.g., X_Custom_Header) cannot be
distinguished from hyphenated headers (X-Custom-Header) after
passing through nginx/uWSGI. This is a CGI/WSGI specification
limitation, not specific to this implementation.
REQUEST_METHODGET	PATH_INFO/QUERY_STRINGr   ?HTTPSr   zwsgi.url_schemeHTTP_:   NN_-CONTENT_TYPEzCONTENT-TYPECONTENT_LENGTHzCONTENT-LENGTHN)on1true)r    getr   r   r   r   lowerr   items
startswithreplacer   append)r)   rR   rT   header_names   &   r+   rB   "UWSGIRequest._extract_request_info   sU   2 oo))*:EB OO''S9	__((<
 :::"&))TZZ8DHyyDH ??w+1137JJ!DK$//1//*;<DK ////1JC~~g&&!"gooc37##[$89&##^U$;<((##%5u$=> 2r.   c                    ^ pRV P                   9   d(    \        \        V P                   R,          4      ^ 4      p\	        \        V P                  V4      4      V n        R#   \         d    ^ p L5i ; i)z/Set up the body reader based on CONTENT_LENGTH.rc   N)r    maxr?   
ValueErrorr   r   r   r   )r)   content_lengths   & r+   r(   UWSGIRequest.set_body_reader   sd     t.#!$S9I)J%KQ!O dmm^DE	  #!"#s   &A! !A10A1c                    V P                   '       d   R# V P                  P                  RR4      P                  4       pVR8X  d   R# VR8X  d   R# R# )z@Determine if the connection should be closed after this request.THTTP_CONNECTIONr   closez
keep-aliveF)r   r    rg   rh   )r)   
connections   & r+   should_closeUWSGIRequest.should_close   sK    ??? __(():B?EEG
 <' r.   )r$   r   r   r   r   r   r!   r"   r   r   r   r#   r   r   r   r   r   r   r   r    r   N)r   )__name__
__module____qualname____firstlineno____doc__r,   r%   r8   r&   r=   rA   rB   r(   rx   __static_attributes____classdictcell__)__classdict__s   @r+   r	   r	      s@     %N;6#%N5?nF r.   r	   N)	gunicorn.http.bodyr   r   gunicorn.uwsgi.errorsr   r   r   rL   r	    r.   r+   <module>r      s'   
 2  _ _r.   