+
    j                       R t ^ RIt^ RIt^ RIt^ RIt^ RIHt ^ RIHtH	t	H
t
HtHtHt ^ RIHt ^ RIHt ^ RIHt  ! R R4      tR	 tR
 t/ tRtRsRs]! R4       U u/ uF  q V R R2P9                  R4      bK  	  up tRt ! R R4      tR t R t! ! R R4      t" ! R R4      t# ! R R]PH                  4      t%R# u up i )z
ASGI protocol handler for gunicorn.

Implements asyncio.Protocol to handle HTTP/1.x and HTTP/2 connections
and dispatch to ASGI applications.
N)AsyncUnreader)PythonProtocolCallbackRequest
ParseErrorLimitRequestLineLimitRequestHeadersInvalidChunkExtension)AsyncUWSGIRequest)
NoMoreData)UWSGIParseExceptionc                   .   a  ] tR t^t o RtRtR tRtV tR# )_RequestTimezLightweight request time container compatible with logging atoms.

Uses time.monotonic() elapsed seconds instead of datetime.now() syscalls.
Provides .seconds and .microseconds attributes for glogging.py compatibility.
c                t    \        V4      V n        \        WP                  ,
          R ,          4      V n        R# )i@B N)intsecondsmicroseconds)selfelapseds   &&K/var/www/idalgo/venv/lib/python3.14/site-packages/gunicorn/asgi/protocol.py__init___RequestTime.__init__$   s&    7|<<!79 DE    )r   r   N)r   r   )	__name__
__module____qualname____firstlineno____doc__	__slots__r   __static_attributes____classdictcell____classdict__s   @r   r   r      s      ,IF Fr   r   c                :    V '       d   \        V R,          4      # R# )zNormalize socket address to ASGI-compatible (host, port) tuple.

ASGI spec requires server/client to be (host, port) tuples.
IPv6 sockets return 4-tuples (host, port, flowinfo, scope_id),
so we extract just the first two elements.
:N   NN)tuple)sockaddrs   &r   _normalize_sockaddrr&   )   s     #+5"44r   c                    \        V \        4      '       g   R# RV9   d   R#  \        P                  ! V ^ ,          4      pT F  pY49   g   K   R# 	  R#   \         d     R# i ; i)zzCheck if peer address is in the trusted proxy list.

Cached at connection start to avoid repeated IP parsing per request.
F*T)
isinstancer$   	ipaddress
ip_address
ValueError)	peer_addr
allow_listnetworksipnetworks   &&&  r   _check_trusted_proxyr2   3   se    
 i''
j!!)A,/ =    s   A A#"A#s   Server: gunicorn/asgi
r   g        i @  x
latin-1i   c                   L   a  ] tR t^Ut o RtR
tR tR tR tR t	R t
R tRtV tR	# )FlowControlzManage transport-level write flow control.

Blocks send() when transport buffer exceeds high water mark,
preventing memory issues with large streaming responses.
c                    Wn         R V n        R V n        \        P                  ! 4       V n        V P
                  P                  4        R# FN)
_transportread_pausedwrite_pausedasyncioEvent_is_writable_eventset)r   	transports   &&r   r   FlowControl.__init__]   s7    # !")--/##%r   c                V   "   V P                   P                  4       G Rj  xL
  R#  L5i)z!Wait until transport is writable.N)r?   waitr   s   &r   drainFlowControl.draind   s     %%**,,,s   )')c                p    V P                   '       g$   R V n         V P                  P                  4        R# R# TN)r;   r:   pause_readingrE   s   &r   rJ   FlowControl.pause_readingh   s+    #DOO))+  r   c                p    V P                   '       d$   R V n         V P                  P                  4        R# R# r9   )r;   r:   resume_readingrE   s   &r   rM   FlowControl.resume_readingm   s+    $DOO**, r   c                p    V P                   '       g$   R V n         V P                  P                  4        R# R# rI   )r<   r?   clearrE   s   &r   pause_writingFlowControl.pause_writingr   s-        $D##))+ !r   c                p    V P                   '       d$   R V n         V P                  P                  4        R# R# r9   )r<   r?   r@   rE   s   &r   resume_writingFlowControl.resume_writingw   s-     %D##'') r   )r?   r:   r;   r<   N)r:   r;   r<   r?   )r   r   r   r   r   r   r   rF   rJ   rM   rQ   rT   r   r   r    s   @r   r7   r7   U   s5     
 TI&-,
-
,
* *r   r7   c                     \         P                   ! 4       p V \        ,
          R8  d%   ^ RIHp RV! RR7       R2P	                  R4      sV s\
        # )z1Get cached Date header, updating once per second.      ?)
formatdatezDate: T)usegmtr4   r5   )time_cached_date_timeemail.utilsrX   encode_cached_date_header)nowrX   s     r   _get_cached_date_headerr`   }   sL     ))+C
#%* &z'>&?tDKKIVr   c           	         W3pV\         9  d6   RV ^ ,           RV ^,           RV RV R2	pVP                  R4      \         V&   \         V,          # )zGet cached status line bytes.HTTP/. r4   r5   )_CACHED_STATUS_LINESr]   )versionstatusreasonkeylines   &&&  r   _get_cached_status_linerk      sZ    
C
&&wqzl!GAJ<q&F$(KK	$:S!$$r   c                   *   a  ] tR t^t o RtR tRtV tR# )ASGIResponseInfoz;Simple container for ASGI response info for access logging.c                   Wn         W0n        . V n        V Fo  w  rE\        V\        4      '       d   VP                  R 4      p\        V\        4      '       d   VP                  R 4      pV P                  P                  WE34       Kq  	  R# )r5   N)rg   sentheadersr)   bytesdecodeappend)r   rg   rp   ro   namevalues   &&&&  r   r   ASGIResponseInfo.__init__   si    	"KD$&&{{9-%''Y/LL. #r   )rp   ro   rg   N)r   r   r   r   r   r   r   r   r    s   @r   rm   rm      s     E
/ 
/r   rm   c                   t   a  ] tR t^t o RtRtR tR tR tR t	]
R 4       tR tR tR	 tR
 tR tR tRtV tR# )BodyReceiverzBody receiver for callback-based parsers.

Body chunks are fed directly via the feed() method from parser callbacks.
Uses Future-based waiting for efficient async receive().
c                r    Wn         W n        . V n        R V n        R V n        R V n        R V n        RV n        R# r9   )requestprotocol_chunks	_complete_body_finished_closed_body_wait_expired_waiter)r   rz   r{   s   &&&r   r   BodyReceiver.__init__   s:     # "'r   c                p    V'       d.   V P                   P                  V4       V P                  4        R# R# )z7Feed a body chunk directly (called by parser callback).N)r|   rs   _wake_waiterr   chunks   &&r   feedBodyReceiver.feed   s(    LL& r   c                4    RV n         V P                  4        R# )z1Mark body as complete (called when message ends).TN)r}   r   rE   s   &r   set_completeBodyReceiver.set_complete   s    r   c                4    RV n         V P                  4        R# )z/Signal that the client transport has gone away.TN)r   r   rE   s   &r   signal_disconnectBodyReceiver.signal_disconnect   s    r   c                B    V P                   ;'       g    V P                  # )z?True when the receiver should yield http.disconnect to the app.)r   r   rE   s   &r   _disconnectedBodyReceiver._disconnected   s     ||66t666r   c                    V P                   e@   V P                   P                  4       '       g   V P                   P                  R4       R# R# R# )z#Wake up any pending receive() call.N)r   done
set_resultrE   s   &r   r   BodyReceiver._wake_waiter   s9    <<#DLL,=,=,?,?LL##D) -@#r   c                  "   V P                   '       d   RR/# V P                  '       d   V P                  4       G Rj  xL
  RR/# V P                  '       d   V P	                  4       # V P
                  '       d   RV n        RRRRRR	/# V P                  P                  ^ 8X  d3   V P                  P                  '       g   RV n        RV n        RRRRRR	/# V P                  P                  '       d   RV n
        RR/#  V P                  4       G Rj  xL
  V P                  4       #  L L  \        P                   d    RR/u # i ; i5i)
z:ASGI receive callable - returns body chunks or disconnect.typehttp.disconnectNThttp.requestbodyr   	more_bodyF)r   r~   _wait_for_disconnectr|   
_pop_chunkr}   rz   content_lengthchunkedr{   r   _wait_for_data_build_receive_resultr=   CancelledErrorrE   s   &r   receiveBodyReceiver.receive   sC     -.. ++----.. <<<??$$ >>>"&DNFCeLL <<&&!+DLL4H4H4H!DN"&DNFCeLL ==   DL-..	/%%'''--//5 .2 (%% 	/-..	/sc   (E
E
D'E
!E
;AE
1E
3E
?D+ D)D+ &E
)D+ +EE
EE
c                    V P                   P                  ^ 4      p\        V P                   4      ;'       g    V P                  '       * pV'       g   RV n        RRRVRV/# )z/Pop a chunk and return the appropriate message.Tr   r   r   r   )r|   popboolr}   r~   )r   r   mores   &  r   r   BodyReceiver._pop_chunk   sQ      #DLL!77%7"&D{DIIr   c                    V P                   '       d   RR/# V P                  '       d   V P                  4       # V P                  '       d   RV n        RRRRRR/# RV n        RR/# )	z,Build receive result after waiting for data.r   r   Tr   r   r   r   F)r   r|   r   r}   r~   r   rE   s   &r   r   "BodyReceiver._build_receive_result  sj    -..<<<??$$>>>"&DNFCeLL
 #')**r   c                  "   V P                   '       g%   V P                  '       g   V P                  '       d   R# \        P                  ! 4       pVP                  4       V n        \        V P                  RR4      pVe   \        VRR4      MRpV'       d   V^ 8:  d   Rp \        P                  ! V P                  VR7      G Rj  xL
  RV n        R#  L  \        P                   d    RT n         L)i ; i  RT n        i ; i5i)z*Wait for body data to arrive via callback.Ncfgtimeout      >@r   T)r|   r}   r   r=   get_event_loopcreate_futurer   getattrr{   wait_forTimeoutErrorr   )r   loopr   r   s   &   r   r   BodyReceiver._wait_for_data  s     <<<4>>>T-?-?-? %%'))+
 dmmUD136?'#y$/'Q,G
	 ""4<<AAA  DL B## 	+ '+D#	+  DLsX   $DDAD	D!%C CC 	DC C52C8 4C55C8 8	DDc                z  "   V P                   '       d   R# V P                  P                   '       d
   RV n         R# \        P                  ! 4       pVP	                  4       V n         V P
                  G Rj  xL
  RV n        RV n         R#  L  \        P                   d     L)i ; i  RT n        RT n         i ; i5i)zWait for connection to close after body is finished.

This is needed for ASGI apps (like Django) that call receive()
to listen for client disconnect after the request body is consumed.
NT)r   r{   r=   r   r   r   r   )r   r   s   & r   r   !BodyReceiver._wait_for_disconnect3  s      <<< ==   DL %%'))+	 ,,  DLDL %% 		  DLDLsL   0B;3B;'B 6B7B ;B;B B%"B( $B%%B( (B88B;)r~   r   r|   r   r}   r   r{   rz   N)r|   r}   r~   r   r   r   rz   r{   )r   r   r   r   r   r   r   r   r   r   propertyr   r   r   r   r   r   r   r   r   r    s   @r   rx   rx      s_     II 

 7 7*
%/NJ+$ :   r   rx   c                   t  a  ] tR tRt o RtRtRtRtRtRt	Rt
R tR t]R 4       tR2tR tR	 tR
 tR tR tR tR tR tR tR tR tR tR tR tR tR tR t R t!R t"R t#R t$R t%R t&R t'R  t(R! t)R" t*R# t+R$ t,]-R% 4       t.]-R& 4       t/]R' 4       t0R3R( lt1R) t2R* t3R+ t4R, t5R- t6R. t7R/ t8R0 t9R1t:V t;R# )4ASGIProtocoliO  zHTTP/1.1 protocol handler for ASGI applications.

Handles connection lifecycle, request parsing, and ASGI app invocation.
Uses callback-based parsing (H1CProtocol/PythonProtocol) for efficient
incremental parsing in data_received().
NFc                f   Wn         VP                  V n        VP                  V n        VP                  V n        R V n        R V n        R V n        R V n        ^ V n	        RV n
        R V n        R V n        RV n        RV n        R V n        R V n        R V n        R V n        RV n        R V n        R V n        R # )NFi   )workerr   logasgiapprA   readerwriter_task	req_countr   _body_receiver_response_buffer_reading_paused_max_buffer_size_keepalive_handle_callback_parser_request_ready_current_request_is_ssl_flow_control
_websocket)r   r   s   &&r   r   ASGIProtocol.__init___  s    ::::;;
 " !%  % ) "& !%" $ " r   c                   Wn         V P                  ;P                  ^,          un        VP                  R4      pV'       d   \	        VR4      '       dm   VP                  4       pVR8X  dV   \        P                  ! 4       V n        V P                  P                  P                  V P                  W4      4      V n        R# VRJV n        Wn        \        V4      V n        VP#                  \$        R7       \        P&                  ! 4       V n        V P+                  4        V P                  P                  P                  V P-                  4       4      V n        R# )z(Called when a connection is established.
ssl_objectselected_alpn_protocolh2N)high)rA   r   nr_connsget_extra_infohasattrr   r=   StreamReaderr   r   create_task_handle_http2_connectionr   r   r   r7   r   set_write_buffer_limitsHIGH_WATER_LIMITr>   r   _setup_callback_parser_handle_connection)r   rA   r   alpns   &&  r   connection_madeASGIProtocol.connection_made  s   "! --l;
'*.FGG446Dt|%224![[--9911)H
  "- )3))/?)@ &mmo##%[[%%11$2I2I2KL
r   c                `   V P                   fl    ^ RIp^ RIHp RV n         W n        \	        VR4      V n        \        VRR4      V n        \        VRR4      V n        \        VRR4      V n	        V P                   # V P                   #   \         d    RT n         RT n         T P                   # i ; i)z:Check if H1CProtocol is available (cached at class level).N)H1CProtocolTr   r   r   F)_h1c_availablegunicorn_h1cr   _h1c_protocol_classr   _h1c_has_limitsr   _h1c_limit_request_line_h1c_limit_request_headers_h1c_invalid_chunk_extensionImportError)clsr   r   s   &  r   _check_h1c_protocol_available*ASGIProtocol._check_h1c_protocol_available  s     %,#4%)"*5'&-l<N&O#.5 "4d/+ 29 "72. 4; "9440 !!!s!!!  ,%*"&+#!!!,s   AB B-,B-c                v   \        V P                  RR4      p. pV P                   F3  p\        V P                  VR4      '       g   K"  VP                  V4       K5  	  \        V P                  RR4      R8w  d   VP                  R4       VR8X  d   \        pMVR8X  d}   V P                  4       '       g   \        R4      h\        P                  '       g   \        R	4      hV'       d"   \        R
RP                  V4      ,          4      h\        P                  pMKV P                  4       '       d0   \        P                  '       d   V'       g   \        P                  pM\        pV P                  P                  pV^ 8X  d   V\        8w  d   RpRV P                  RV P                  RV P                  RVRV P                  P                  RV P                  P                   RV P                  P"                  RV P                  P$                  /pV\        J d   \        V P                  RR4      pVR8w  dp   V P&                  P)                  R4      p\+        V4      p	\-        V	V P                  P.                  V P                  P1                  4       4      p
V
'       d   TMRVR&   MRVR&   V! R/ VB V n        R# )a  Create callback parser based on http_parser setting.

Parser selection:
- auto: Use H1CProtocol if available (>= 0.4.1) and no incompatible flags, else PythonProtocol
- fast: Require H1CProtocol >= 0.4.1 (error if unavailable or incompatible flags)
- python: Use PythonProtocol only
http_parserautoFproxy_protocoloffpythonfastz,gunicorn_h1c required for http_parser='fast'zigunicorn_h1c >= 0.4.1 required for http_parser='fast'. Please upgrade: pip install --upgrade gunicorn_h1czqhttp_parser='fast' is incompatible with compatibility flags: %s. Use http_parser='python' or disable these flags.z, on_headers_completeon_bodyon_message_completelimit_request_linelimit_request_fieldslimit_request_field_size!permit_unconventional_http_method"permit_unconventional_http_versionpeernameNi    )r   r   _FAST_PARSER_INCOMPATIBLE_FLAGSrs   r   r   RuntimeErrorr   r   joinr   r   _on_headers_complete_on_body_on_message_completer   r   r   r   rA   r   r&   r2   proxy_allow_ipsproxy_allow_networksr   )r   parser_settingincompatibleflagparser_classr   parser_kwargs	cfg_proxyr   
normalizedtrusteds   &          r   r   #ASGIProtocol._setup_callback_parser  sU    !=&A 88Dtxxu--##D) 9
 488-u5> 01X%)Lv%5577"#QRR///"I  "Gii-. 
 (;;L2244 000+??- "XX88"|~'E!,
 "4#<#<t}}!4#<#< "4"DHH$A$A&(I(I/1[1[0$((2]2]	
 >)  *:EBIE!>>88D0:
.HH,,HH113
 @G)E./27./ , =} =r   c                $   \         P                  ! V P                  V P                  R7      V n        \        V P                  V 4      V n        V P                  '       d   V P                  P                  4        V P                  P                  R8H  # )z'Callback: request headers are complete.)is_ssls   HEAD)
r   from_parserr   r   r   rx   r   r   r@   methodrE   s   &r   r  !ASGIProtocol._on_headers_complete  sv     !0 ; ;!!$,,!

 +4+@+@$G ##% $$++w66r   c                d    V P                   '       d   V P                   P                  V4       R# R# )z#Callback: received body data chunk.N)r   r   r   s   &&r   r  ASGIProtocol._on_body'  s'    $$U+ r   c                b    V P                   '       d   V P                   P                  4        R# R# )z$Callback: request is fully received.N)r   r   rE   s   &r   r  !ASGIProtocol._on_message_complete,  s%    ,,. r   c                   \         P                  pVe?   \        W4      '       d.   V P                  R\	        V4      4       V P                  4        R# \         P                  pVe?   \        W4      '       d.   V P                  R\	        V4      4       V P                  4        R# \         P                  pVe?   \        W4      '       d.   V P                  R\	        V4      4       V P                  4        R# R# )zHandle gunicorn_h1c exceptions with appropriate HTTP status codes.

Returns True if the exception was handled, False otherwise.
  T    F)r   r   r)   _send_error_responsestr_close_transportr   r   )r   exch1c_limit_lineh1c_limit_headersh1c_chunk_exts   &&   r   _handle_h1c_exception"ASGIProtocol._handle_h1c_exception1  s     &==%*S*I*I%%c3s84!!#(CC(Z-O-O%%c3s84!!#$AA$C)G)G%%c3s84!!#r   c                   V P                   '       d   V P                   P                  V4       R# V P                  '       d   V P                  P                  V4       M+V P                  '       d   V P	                  V4      '       g   R# V P
                  '       g+   V P                  4       '       d   V P                  4        R# R# R# )z/Called when data is received on the connection.N)r   	feed_datar   r   _feed_callback_parserr   _is_buffer_full_pause_reading)r   datas   &&r   data_receivedASGIProtocol.data_receivedH  s    ???OO%%d+;;;KK!!$'"""--d33 ###(<(<(>(>! )?#r   c                &    V P                   P                  V4       R#   \         d7   pT P                  R\	        T4      4       T P                  4         Rp?R# Rp?i\         d7   pT P                  R\	        T4      4       T P                  4         Rp?R# Rp?i\        \        3 d7   pT P                  R\	        T4      4       T P                  4         Rp?R# Rp?i\         d$   pT P                  T4      '       d    Rp?R# h Rp?ii ; i)zFeed data to callback parser, handling parse errors.

Returns True if parsing should continue, False if connection was closed.
Tr  NFr  r  )r   r   r   r   r!  r"  r   r   r   	Exceptionr'  r   r.  es   && r   r+  "ASGIProtocol._feed_callback_parserZ  s    
	!!&&t, 	%%c3q62!!#" 	%%c3q62!!#%z2 	%%c3q62!!# 	))!,,		sP    D+AD(D)+BD-D.+CD,D-D
DDc                    V P                   '       dI   \        V P                   R4      '       d-   \        V P                   P                  4      V P                  8  # R# )z/Check if internal buffer is full (HTTP/2 only)._bufferF)r   r   lenr7  r   rE   s   &r   r,  ASGIProtocol._is_buffer_fullt  s>    ;;;74;;	::t{{**+d.C.CCCr   c                    V P                   '       g9   V P                  '       d%   RV n          V P                  P                  4        R# R# R#   \        \        3 d     R# i ; i)z1Pause reading from transport due to backpressure.TN)r   rA   rJ   AttributeErrorr  rE   s   &r   r-  ASGIProtocol._pause_readingz  sT    ####'D ,,. )7# #L1    A A"!A"c                    V P                   '       d9   V P                  '       d%   RV n          V P                  P                  4        R# R# R#   \        \        3 d     R# i ; i)zResume reading from transport.FN)r   rA   rM   r;  r  rE   s   &r   _resume_readingASGIProtocol._resume_reading  sT    DNNN#(D --/ %3 #L1 r=  c                   V P                   '       d   V P                   P                  4        V P                  P                  pV^ 8  d7   V P                  P
                  P                  WP                  4      V n         R# R# )z6Arm keepalive timeout timer after response completion.N)r   cancelr   	keepaliver   r   
call_later_keepalive_timeout)r   keepalive_timeouts   & r   _arm_keepalive_timer!ASGIProtocol._arm_keepalive_timer  sc    !!!""))+ HH..q %)[[%5%5%@%@!#:#:&D" !r   c                p    V P                   '       d$   V P                   P                  4        RV n         R# R# )z0Cancel keepalive timer when new request arrives.N)r   rB  rE   s   &r   _cancel_keepalive_timer$ASGIProtocol._cancel_keepalive_timer  s-    !!!""))+%)D" "r   c                &    V P                  4        R# )z&Called when keepalive timeout expires.N)r"  rE   s   &r   rE  ASGIProtocol._keepalive_timeout  s    r   c                   V P                   '       d   R# RV n         V P                  ;P                  ^,          un        V P                  4        V P                  '       d   V P                  P                  4        V P                  '       d   V P                  P                  4        V P                  e   V P                  P                  4        V P                  '       d   V P                  P                  4       '       gm   \        V P                  R^4      pV^ 8  d3   V P                  P                  P                  VV P                  4       R# V P                  P!                  4        R# R# R# )a\  Called when the connection is lost or closed.

Instead of immediately cancelling the task, we signal a disconnect
event and send an http.disconnect message to the receive queue.
This allows the ASGI app to clean up resources (like database
connections) gracefully before the task is cancelled.

See: https://github.com/benoitc/gunicorn/issues/3484
NTasgi_disconnect_grace_period)r   r   r   rJ  r   feed_eofr   r   r   r   r   r   r   r   rD  _cancel_task_if_pendingrB  )r   r#  grace_periods   && r   connection_lostASGIProtocol.connection_lost  s    <<<! 	$$&;;;KK  " ???OO$$& *113 :::djjoo//"488-KQOLa  ++ 00 

!!# 0:r   c                    V P                   '       d?   V P                   P                  4       '       g   V P                   P                  4        R# R# R# )z9Cancel the task if it's still pending after grace period.N)r   r   rB  rE   s   &r   rQ  $ASGIProtocol._cancel_task_if_pending  s2    :::djjoo//JJ 0:r   c                b    V P                   '       d   V P                   P                  4        R# R# )z>Called by transport when write buffer exceeds high water mark.N)r   rQ   rE   s   &r   rQ   ASGIProtocol.pause_writing  s%    ,,. r   c                b    V P                   '       d   V P                   P                  4        R# R# )zBCalled by transport when write buffer drains below low water mark.N)r   rT   rE   s   &r   rT   ASGIProtocol.resume_writing  s%    --/ r   c                T    V P                   P                  V4       R#   \         dk   pTP                  \        P                  \        P
                  \        P                  39  d"   T P                  P                  R4        Rp?R#  Rp?R# Rp?i\        \        3 d     R# i ; i)aH  Write data to transport, handling connection errors gracefully.

Catches exceptions that occur when the client has disconnected:
- OSError with errno EPIPE, ECONNRESET, ENOTCONN
- RuntimeError when transport is closing/closed
- AttributeError when transport is None

These are silently ignored since the client is already gone.
zSocket error writing response.N)rA   writeOSErrorerrnoEPIPE
ECONNRESETENOTCONNr   	exceptionr  r;  r3  s   && r   _safe_writeASGIProtocol._safe_write  sw    	NN  & 	Ewwu{{E,<,<ennMM""#CDD Nn- 		s!    B'ABB'"B'&B'c                  "    V P                   P                  R4      pV P                   P                  R4      p\        V P                  RR4      pVR8X  d-   V P	                  W4      G Rj  xL
   V P                  4        R# V P                  '       EgU   V ;P                  ^,          un        V P                  4        V P                  P                  4       '       g$    V P                  P                  4       G Rj  xL
  V P                  '       g   V P                  f   EMV P                  pV P                  V4      pV P!                  V4      '       d   V P#                  WBV4      G Rj  xL
  EMwV P%                  WBV4      G Rj  xL
 pV P&                  ;P(                  ^,          un        V P&                  P(                  V P&                  P*                  8  d/   V P,                  P/                  R4       RV P&                  n        RpV'       d   V P&                  P0                  '       g   MV P                  P2                  '       g   MV P4                  pVe   VP6                  '       g   MxV P9                  4        V P:                  '       d   V P:                  P=                  4        RV n        RV n        V P                  P?                  4        V PA                  4        EKg   V P                  4        R#  EL EL  \        P                   d     K0  i ; i EL EL  \        P                   d     LQ\B         d'   pT P,                  PE                  R	T4        Rp?L|Rp?ii ; i  T P                  4        i ; i5i)
a  Main request handling loop using callback-based parser.

Uses synchronous parsing in data_received(), avoiding the async
overhead of pull-based parsing. The parser fires callbacks when
headers and body data are available, and this loop waits on
events rather than actively parsing.
r   socknamer{   httpuwsgiN,Autorestarting worker after current request.FzError handling connection: %s)#rA   r   r   r   _handle_connection_uwsgir"  r   r   rJ  r   is_setrD   r=   r   r   _effective_peername_is_websocket_upgrade_handle_websocket_handle_http_requestr   nrmax_requestsr   infoaliverC  r   r}   r?  r   resetrP   rG  r2  rb  )	r   r   rf  protocol_typerz   effective_peerrC  receiverr4  s	   &        r   r   ASGIProtocol._handle_connection  s    V	$~~44Z@H~~44Z@H $DHHj&AM'33HGGG\ !!#Y lll!#,,. **1133"1166888 <<<4#8#8#@// "&!9!9(!C --g6600NSSS #'";";~# 	
 !# ;;>>T[[%=%==HHMM"PQ(-DKK% %I (9(9(9 xx)))  ..'0B0B0B $$& ((())//1 )-%&*###))+ ))+K #X !!#_ H 9"11  TZ %% 	 	CHH>BB	C !!#s(  NA(L& ,K>-L& 2NL& AL& !L >L?L L& L& #M0 %3L& L& .L /L& 3M0 5L& 
L#BL& L& 3M0 4L& M0 !L& 3M0 4!L& AL& +M0 ,N>L& L LL& M0 LL& #L& &M-;M0 =M-M-M(#M0 (M--M0 0NNc                  "   \        V P                  4      pV P                  '       Eg|   V ;P                  ^,          un         \        P
                  ! V P                  VVV P                  4      G Rj  xL
 pT P                  T4      '       d   T P                  YBT4      G Rj  xL
  R# T P                  YBT4      G Rj  xL
 pT P                  ;P                  ^,          un        T P                  P                  T P                  P                   8  d/   T P                  P#                  R4       RT P                  n        RpT'       d   T P                  P$                  '       g   R# T P                  P&                  '       g   R# TP)                  4       G Rj  xL
  EK  R#  EL3  \         d     R# \         d(   pT P                  P                  RT4        Rp?R# Rp?ii ; i ELG EL. LT5i)z0Handle uWSGI protocol connections (legacy path).NzuWSGI parse error: %sri  F)r   r   r   r   r	   parser   r
   r   r   debugrm  rn  ro  r   rp  rq  rr  rs  rC  
drain_body)r   r   rf  unreaderrz   r4  rC  s   &&&    r   rj  %ASGIProtocol._handle_connection_uwsgiM  sz     -,,,NNaN 1 7 7HHNN	!  ))'22,,WIII #778 I
 KKNNaN {{~~!9!99LM$)!!	DKK$5$5$588%%%$$&&&S   & 6: J& 's   (G5G50F+ 5F(6F+ :G5G5&G-'G5G0BG5G5+G5	G5G3	G5(F+ +G*6G59G*G*G%G5%G**G50G53G5c                    VP                   R8w  d   R# RpRpVP                   F7  w  rEVR8X  d   VP                  4       pK  VR8X  g   K'  VP                  4       pK9  	  VR8H  ;'       d    T;'       d    RV9   # )zCheck if request is a WebSocket upgrade.

Per RFC 6455 Section 4.1, the opening handshake requires:
- HTTP method MUST be GET
- Upgrade header MUST be "websocket" (case-insensitive)
- Connection header MUST contain "Upgrade"
GETFNUPGRADE
CONNECTION	websocketupgrade)r  rp   lower)r   rz   r  
connectionrt   ru   s   &&    r   rm  "ASGIProtocol._is_websocket_upgrade|  su     >>U"
"??KDy ++-%"[[]
	 +
 +%PP*PPj9PPr   c                   "   ^ RI Hp RV n        V P                  WV4      pV! V P                  WPP
                  V P                  4      pW`n        VP                  4       G Rj  xL
  R#  L5i)z!Handle WebSocket upgrade request.)WebSocketProtocolN)	gunicorn.asgi.websocketr  r   _build_websocket_scoperA   r   r   r   run)r   rz   rf  r   r  scopews_protocols   &&&&   r   rn  ASGIProtocol._handle_websocket  sX     = !%++GxH'NNE88TXX

 &oos   A!A,#A*$A,c                	  a aaaaaaaaaa"   S P                  SW#4      pRoRoRoRoRoRoRS n        Ro. o^ oS P                  pVVVVVVVVVV V3R lpS P                  P                  p \
        P                  ! 4       pS P                  P                  S P                  S4       S P                  WEP                  V4      G Rj  xL
  Se   ShS'       g   S P                  RR4       Ro \!        \
        P                  ! 4       T,
          4      p	T'       d>   S P#                  SY#4      p
\%        SSS4      pS P                  P'                  TSY4       MRp
RpS P                  P)                  S P                  SY4       SP/                  4       '       d   R# S P                  P0                  ;'       d    S P                  P2                  #  EL	  \        P                   d    S P                  P                  R4         \!        \
        P                  ! 4       X,
          4      p	T'       d>   S P#                  SY#4      p
\%        SSS4      pS P                  P'                  TSY4       MRp
RpS P                  P)                  S P                  SY4       R#   \*         d     S P                  P-                  R4        R# i ; i\*         Ed#    S'       d   S P                  P                  R4       M7S P                  P-                  R	4       S'       g   S P                  RR4       Ro  \!        \
        P                  ! 4       X,
          4      p	T'       d>   S P#                  SY#4      p
\%        SSS4      pS P                  P'                  TSY4       MRp
RpS P                  P)                  S P                  SY4       R#   \*         d     S P                  P-                  R4        R# i ; ii ; i  \*         d     S P                  P-                  R4        ELi ; i   \!        \
        P                  ! 4       X,
          4      p	T'       d>   S P#                  SY#4      p
\%        SSS4      pS P                  P'                  TSY4       MRp
RpS P                  P)                  S P                  SY4       i   \*         d    S P                  P-                  R4        i i ; i; i5i)
zHandle a single HTTP request.FN  c                   <"   SP                   '       d   R # V R,          pVR8X  d8   V P                  R4      pV P                  R. 4      pSP                  W#S4       R # VR8X  Eda   S'       d   \        R4      oR # RoV R,          oV P                  R. 4      oRpRpS FS  w  rg\	        V\
        4      '       d   VP                  4       MVP                  4       pVR9   d   RpKF  VR9   g   KO  RpRoKU  	  SP                  SP                  S4      oS'       d@   V'       g	   V'       d0   SP                  SS4      oSP                  S4      '       d   RpRpRoV'       * ;'       d.    V'       * ;'       d    SP                  R8  ;'       d    S'       * p	V	'       d   Ro\        S4      R.,           oSP                  SSS4       R # VR	8X  Ed   S'       g   \        R
4      oR # S'       d   \        R4      oR # V P                  RR4      p
V P                  RR4      pS'       d<   V
'       d2   S'       g*   SP                  P                  RSP                  S4       RoRp
V
'       dZ   SP!                  V
SR7       S\#        V
4      ,          oSP$                  '       d#   SP$                  P'                  4       G R j  xL
  V'       g   S'       dO   SP(                  '       d+   SP+                  SP(                  R,           4       R Sn        MFSP+                  R4       M4SP(                  '       d#   SP+                  SP(                  4       R Sn        RoR # R # R #  L5i)Nr   http.response.informationalrg   rp   http.response.startResponse already startedTFhttp.response.bodyResponse not startedResponse already completer   r   r   z\ASGI app sent body bytes on a no-body response (method=%s status=%s); dropping per RFC 9110.)r   s   0

)   content-lengthcontent-length)   transfer-encodingtransfer-encoding   r  )r  s   chunked)r   get_send_informationalr  r)   r!  r  _response_omits_bodyr  _strip_body_framing_headers _response_forbids_content_lengthrf   list_send_response_startr   warning
_send_bodyr8  r   rF   r   rc  )messagemsg_typeinfo_statusinfo_headershas_content_lengthhas_transfer_encodingrt   _
name_lowerneeds_chunkedr   r   exc_to_raise
omits_bodyomits_body_warnedrz   response_completeresponse_headersresponse_sentresponse_startedresponse_statusr   use_chunkeds   &           r   send/ASGIProtocol._handle_http_request.<locals>.send  s     |||vH88%kk(3&{{9b9((GL00##/0J#KL#' ")("3#*;;y"#=  &+"(-%/GD1;D#1F1FDJJLJ!%JJ-1*#'RR04-&*  0 "66w~~W
#59N'+'G'G(/($ <<_MM-2*,1)"'K +* ' '11' '61' ' '	  !"&K'+,<'=Ac@d'd$))/;KWU11'#/0F#GL$#/0K#LL{{63/#KKU;	 $5((L#NNO
 -1)DOOD+O>!SY.M)))"0066888 "000 ,,T-B-B\-QR48D1 ,,\:...(()>)>?04-(,% !E 2@ 9s   A+M/A:M.+MM"M*(MM'M6MM9MM,8M%M-M52M(AM<M=M	MM#AM1+MInternal Server Errorz'Request cancelled (client disconnected)Exception in post_request hookz7Exception after response complete (client disconnected)Error in ASGI application)_build_http_scoper   r   r   access_log_enabledrZ   	monotonicr   pre_requestr   r   r   r   r=   r   r{  r   _build_environrm   accesspost_requestr2  rb  should_closers  rC  )r   rz   rf  r   r  body_receiverr  r  request_startrequest_timeenvironrespr  r  r  r  r  r  r  r  r  s   ff&&        @@@@@@@@@r   ro  !ASGIProtocol._handle_http_request  s    &&wC !
! !%  ++r	- r	-j "XX88/	E NN,MHH  g6((5"7"7>>>'"" $))#/FG"%.E+DNN,<},LM%"11'8NG+O=M}]DHHOOD'7I"GD%%dkk7GJ
 !!{{  77TXX%7%77c ? %% 	HHNNDE$E+DNN,<},LM%"11'8NG+O=M}]DHHOOD'7I"GD%%dkk7GJ E""#CDE9  
	 !XY""#>?'--c3JK&)OE+DNN,<},LM%"11'8NG+O=M}]DHHOOD'7I"GD%%dkk7GJ E""#CDE9
	8  E""#CDEE+DNN,<},LM%"11'8NG+O=M}]DHHOOD'7I"GD%%dkk7GJ E""#CDEs  AS,,AG GG G .BO8 S,S,8S,G 0O5P% BJ S,&KS,KS,	O5O5>O5O5.P% 0BO S,&O1-S,0O11S,4O55P% 8&P"S,!P""S,%S)'BR=<S)=&S&#S)%S&&S))S,c                   \        VRR4      p\        V\        4      '       d   \        V4      pMV. pVP                   FD  w  rgVP	                  VP                  4       P                  R4      VP                  R4      34       KF  	  \        V4      p\        V4      p	RRRRRR	R
/RVP                  ^ ,           RVP                  ^,           2RVP                  RVP                  RVP                  RVP                  '       d   VP                  MRRVP                  '       d   VP                  P                  R4      MRRV P                  P                  ;'       g    RRVRVRV	/p
\!        V P"                  R4      '       d   V P"                  P$                  V
R&   \!        VR4      '       d    RRVP&                  RVP(                  //V
R&   V
# )z*Build ASGI HTTP scope from parsed request.headers_bytesNr5   r   rg  r   rf   3.0spec_version2.4http_versionrc   r  schemepathraw_pathr   query_string	root_path rp   serverclientstatepriority_weighthttp.response.priorityweight
depends_on
extensions)r   r)   r  rp   rs   r  r]   r&   rf   r  r  r  r  queryr   r  r   r   r  r  priority_depends_on)r   rz   rf  r   r  rp   rt   ru   r  r  r  s   &&&&       r   r  ASGIProtocol._build_http_scopee  s     $?mT**=)GG&

 3 3I >Y@WXY  / %X.$X. FY~u=wq12!GOOA4F3GHgnngnnGLLG,<,<,<((#w}}}GMM00;RU++11rwff
  4;;((![[..E'N 7-..(g55 '"="=+#E, r   c                \   RVP                   RVP                  RVP                  RVP                  ;'       g    RRRVP                  ^ ,           RVP                  ^,           2R	V'       d
   V^ ,          MR
/pVP
                   F"  w  rVRVP                  R
R4      ,           pWdV&   K$  	  V# )z8Build minimal WSGI-like environ dict for access logging.REQUEST_METHODRAW_URI	PATH_INFOQUERY_STRINGr  SERVER_PROTOCOLrb   rc   REMOTE_ADDR-HTTP_r  )r  urir  r  rf   rp   replacer   rz   rf  r   r  rt   ru   ri   s   &&&&    r   r  ASGIProtocol._build_environ  s     gnnw{{GMM//Rwq'9&:!GOOA<N;OP(8A;
 #??KDDLLc22C CL + r   c                   . pVP                    FD  w  rVVP                  VP                  4       P                  R4      VP                  R4      34       KF  	  . pVP                    F;  w  rVVR8X  g   K  VP	                  R4       Uu. uF  qP                  4       NK  	  pp M	  \        V4      p	\        V4      p
RRRRRR	R
/RVP                  ^ ,           RVP                  ^,           2RVP                  R8X  d   RMRRVP                  RVP                  '       d   VP                  MRRVP                  '       d   VP                  P                  R4      MRRV P                  P                  ;'       g    RRVRV	RV
RV/p\        V P                  R4      '       d   V P                  P                   VR&   V# u upi )z/Build ASGI WebSocket scope from parsed request.r5   zSEC-WEBSOCKET-PROTOCOL,r   r  r   rf   r  r  r  r  rc   r  httpswsswsr  r  r   r  r  r  rp   r  r  subprotocolsr  )rp   rs   r  r]   splitstripr&   rf   r  r  r  r  r   r  r   r   r  )r   rz   rf  r   rp   rt   ru   r  sr  r  r  s   &&&&        r   r  #ASGIProtocol._build_websocket_scope  s    "??KDNNDJJL//	:ELL<STU + "??KD//38;;s3CD3Ca	3CD +
 %X.$X. KY~u=wq12!GOOA4F3GHw~~8edGLLG,<,<,<((#w}}}GMM00;RU++11rwffL
  4;;((![[..E'N3  Es   F<c           	        VP                   R8  d   R# V P                  V4      pRVP                   ^ ,           RVP                   ^,           RV RV R2	pV Fa  w  rg\        V\        4      '       d   VP	                  R4      p\        V\        4      '       d   VP	                  R4      pWV RV R2,          pKc  	  VR,          pV P                  VP                  R4      4       R# )	a7  Send an informational response (1xx) such as 103 Early Hints.

Args:
    status: HTTP status code (100-199)
    headers: List of (name, value) header tuples
    request: The parsed request object

Note: Informational responses are only sent for HTTP/1.1 or later.
HTTP/1.0 clients do not support 1xx responses.
Nrb   rc   rd   r4   r5   z: r  )rf   _get_reason_phraser)   rq   rr   rc  r]   )r   rg   rp   rz   rh   responsert   ru   s   &&&&    r   r   ASGIProtocol._send_informational  s     ??V#((07??1-.a0B/C1VHAfXUYZ"KD$&&{{9-%''Y/&5'..H # 	F34r   c                0   V P                  V4      p\        VP                  W4      pV.pRpRpV F  w  r\        V	\        4      '       d#   V	P                  4       pVP                  V	4       M?V	P                  4       P                  R4      pVP                  V	P                  R4      4       VP                  R4       \        V
\        4      '       d   VP                  V
4       M VP                  V
P                  R4      4       VP                  R4       VR8X  d   RpK  VR8X  g   K  RpK  	  V'       g   VP                  \        4       V'       g   VP                  \        4       4       VP                  R4       RP                  V4      V n        R	# )
zSend HTTP response status and headers.

Uses cached status lines and headers for common cases to avoid
repeated string formatting and encoding.
Fr5   s   :    
s   dateTs   serverr   N)r  rk   rf   r)   rq   r  rs   r]   _CACHED_SERVER_HEADERr`   r  r   )r   rg   rp   rz   rh   status_linepartshas_date
has_serverrt   ru   r  s   &&&&        r   r  !ASGIProtocol._send_response_start  s7    ((0-goovN 
"KD$&&!ZZ\
T"!ZZ\00;
T[[34LL%''U#U\\)45LL! W$y(!
+ #0 LL./LL023W !$r   c                x   \        V P                  RR4      R8X  d   V# \        VV P                  P                  V P                  P	                  4       4      '       g   V# V P
                  pV'       d   \        VRR4      MRpV'       g   V# VP                  R4      pVP                  R4      pVe   Vf   V# WE3# )a  Return the client address advertised via PROXY protocol if any.

Falls back to the transport peername when PROXY protocol is disabled,
the framing was absent, the parser is the C variant (which currently
does not surface PROXY metadata), or the transport peer is not in
``proxy_allow_ips`` (defense-in-depth: ``_setup_callback_parser``
already disables PROXY parsing for untrusted peers).
r   r   proxy_protocol_infoNclient_addrclient_port)r   r   r2   r  r	  r   r  )r   r   parserrr  r	  r
  s   &&    r   rl   ASGIProtocol._effective_peername  s     488-u5>O#HH$$HH))+
 

 O&&?Ewv4d;4Ohh}-hh}-+"5O))r   c                b    V R8H  ;'       g$    VR9   ;'       g    ^dTu;8*  ;'       d    ^8  # u # )zReturn True when the response MUST NOT have a body (RFC 9110).

Applies to HEAD requests and to status codes that semantically carry no body:
1xx informational, 204 No Content, 304 Not Modified.
HEAD)   0  r  )r  rg   s   &&r   r  !ASGIProtocol._response_omits_body3  sG     f # ### #f""s"	
 #	
r   c                H    V ^8H  ;'       g    ^dT u;8*  ;'       d    ^8  # u # )u  Per RFC 9110 §6.4.2 a server MUST NOT send Content-Length on 1xx
or 204 responses.  HEAD and 304 are NOT covered: HEAD MAY include the
Content-Length the same GET would have returned, and 304 MAY include
the Content-Length the unconditional response would have carried.
r  )rg   s   &r   r  -ASGIProtocol._response_forbids_content_length@  s)     }33v 3 3 33 33r   c                   RR0pV P                  V4      '       d   VP                  RR04       V UUu. uFE  w  rE\        V\        4      '       d   VP	                  4       MVP	                  4       V9  g   KB  WE3NKG  	  upp# u uppi )a  Remove framing headers that must not appear on a no-body response.

Transfer-Encoding is always stripped (chunked framing implies a body
we will not send).  Content-Length is stripped only when the status
forbids it (1xx / 204); HEAD and 304 keep app-supplied Content-Length.
r  r  r  r  )r  updater)   r!  r  )r   rp   rg   	forbiddennvs   &&&   r   r  (ASGIProtocol._strip_body_framing_headersI  s     *+>?	//77/1ABC&
&tq'3//	QWWYyP QFw
 	
 
s   ?B8Bc                (   V'       d   V'       dN   \        V4      p\        P                  V4      ;'       g    VR R2P                  R4      pWA,           R,           pMRpV P                  '       d,   V P                  V P                  V,           4       RV n        R# V'       d   V P                  V4       R# R# V P                  '       d,   V P                  V P                  V,           4       RV n        R# V'       d   V P                  V4       R# R# )ziSend response body chunk.

Combines buffered headers with first body chunk for efficient write batching.
r3   r4   r5   r   r   N)r8  _CHUNK_PREFIXESr  r]   r   rc  )r   r   r   sizeprefix
chunk_datas   &&&   r   r  ASGIProtocol._send_bodyY  s    
  4y(,,T2WWao6L6LY6W#]W4
 
 $$$  !6!6!CD(,%  ,  $$$  !6!6!=>(,%  & r   c                    VP                  R4      pRV RV R\        V4       R2pV P                  VP                  R4      4       V P                  V4       R# )zSend an error response.zutf-8z	HTTP/1.1 rd   z,
Content-Type: text/plain
Content-Length: z
Connection: close

r5   N)r]   r8  rc  )r   rg   r  r   r  s   &&&  r   r   !ASGIProtocol._send_error_responsev  sa    ~~g&xq	 *"4yk * 	 	34r   c                    / ^dRb^eRb^gRb^Rb^Rb^Rb^Rb^RbR	R
bRRbRRbRRbRRbRRbRRbRRbRRb/ RRbRRbRR bR!R"bR#R$bR%R&bR'R(bR)R*bR+R,bR-R.bR/R0bR1R2bR3R4bR5R6bR7R8bR9R:bCpVP                  VR;4      # )<z'Get HTTP reason phrase for status code.ContinuezSwitching ProtocolszEarly HintsOKCreatedAcceptedz
No ContentzPartial Contenti-  zMoved Permanentlyi.  Foundi/  z	See Otherr  zNot Modifiedi3  zTemporary Redirecti4  zPermanent Redirectr  zBad Requesti  Unauthorizedi  	Forbiddeni  z	Not Foundi  zMethod Not Allowedi  zRequest Timeouti  Conflicti  Gonei  zLength Requiredi  zPayload Too Larger  zURI Too Longi  zUnsupported Media Typei  zUnprocessable Entityi  zToo Many Requestsr  r  i  zNot Implementedi  zBad Gatewayi  zService Unavailablei  zGateway TimeoutUnknown)r  )r   rg   reasonss   && r   r  ASGIProtocol._get_reason_phrase  s   "
"
&"
 "
 	"

 "
 "
 "
 ""
 $"
 "
 "
 "
 %"
 %"
 "
  !"
" #"
$ %"
& %'"
( ")"
* +"
, -"
. "/"
0 $1"
2 3"
4 )5"
6 '7"
8 $9"
: (;"
< "="
> ?"
@ &A"
B "C"
F {{69--r   c                0   V P                   '       ds   V P                  '       g_    V P                   P                  4       '       d   V P                   P                  4        V P                   P	                  4        RV n        R# R# R#   \
         d     Li ; i)zClose the transport safely.

Calls write_eof() first if supported to signal end of writing,
which helps ensure buffered data is flushed before closing.
TN)rA   r   can_write_eof	write_eofcloser2  rE   s   &r   r"  ASGIProtocol._close_transport  sq     >>>$,,,>>//11NN,,.$$&  DL #/>  s   B 4B BBc           	       "    ^ RI Hp VP                  R4      pVP                  R4      pV P                  p\        P
                  ! V4      p\        P                  ! WW`P                  P                  4      pV! V P                  WhV4      p	V	P                  4       G Rj  xL
  Wn        V	P                  '       Eg   V P                  P                  '       d    V	P                  RR7      G Rj  xL
 p
T
 FC  p T P'                  YYT4      G Rj  xL
  T	P3                  TP,                  P.                  4       KE  	  T P                  ;P4                  \7        T
4      ,          un        T P                  P4                  T P                  P8                  8  g   K  T P"                  P;                  R
4       RT P                  n         \?        T R4      '       d$    T P                  PA                  4       G Rj  xL
  T PC                  4        R#  ELo EL"  \        P                   d     EK  \          d(   pT P"                  P%                  RT4        Rp?K  Rp?ii ; i ELR  \          dw   pT P"                  P)                  R4        T	P+                  TP,                  P.                  R	\1        T4      4      G Rj  xL 
   Rp?EL  \          d	      Rp?ELi ; iRp?ii ; i  T	P3                  TP,                  P.                  4       i ; i  \        P<                   d     ELc\          d(   pT P"                  P)                  RT4        Rp?ELRp?ii ; i ELg  \          d     ELsi ; i  \?        T R4      '       d7    T P                  PA                  4       G Rj  xL 
  M  \          d     Mi ; iT PC                  4        i ; i5i)zHandle an HTTP/2 connection.)AsyncHTTP2Connectionr   rf  NrW   r   zHTTP/2 receive error: %szError handling HTTP/2 requestr  ri  FzHTTP/2 connection error: %s_h2_conn)"gunicorn.http2.async_connectionr5  r   r   r=   StreamReaderProtocolStreamWriterr   r   r   initiate_connectionr6  	is_closedrs  receive_datar   r2  r   r{  _handle_http2_requestrb  
send_errorstream	stream_idr!  cleanup_streamrp  r8  rq  rr  r   r   r2  r"  )r   rA   r   r5  r   rf  r   r{   r   h2_connrequestsr4  reqs   &&&          r   r   %ASGIProtocol._handle_http2_connection  s    C	$L //
;H //
;H [[F33F;H))V[[-=-=F
 +&(G --///#M '''DKK,=,=,=%,%9%9#%9%FFH $CE"88(    ..szz/C/CD $" #h-/ ;;>>T[[%=%==HHMM"PQ(-DKK% tZ((----/// !!#c 0  G++   HHNN#=qA % !**+JK!")"4"4 #

 4 4c3q6#    ) ! !!  ..szz/C/CD %% 	 	AHH<a@@	A
 0   tZ((----///  !!#s  OBL  H!L >L H 0H1H 5L ;I%I"I%BL ,L M4 OM" 8M9M" =OL H I*L .I7I8IL M4 IL "I%%K&0K!3K?K KK)KK!K)KK!!K&&K))'LL M(M4 +M4M5MM4 MM4 M" "M1-O0M11O4ON,%N(&N,+O,N:7O9N::OOc                    . pV Ft  w  r4\        V\        4      '       d   VP                  R4      p\        V\        4      '       d   VP                  R4      pVP                  VP	                  4       V34       Kv  	  V# )z?Convert ASGI headers to HTTP/2 format (lowercase string names).r5   )r)   rq   rr   rs   r  )r   rp   resultrt   ru   s   &&   r   _convert_h2_headers ASGIProtocol._convert_h2_headers  sg    "KD$&&{{9-%''Y/MM4::</0 # r   c           
     4  a aaaaaaaaaaa"   VP                   P                  oSP                  P                  S4      oS P	                  WV4      pRoRoRoRoRo. o^ oRoVV3R lpVVVVVVVVV V3
R lpS P
                  P                  p\        P                  ! 4       p	 S P                  P                  S P                  V4       S P                  WVV4      G Rj  xL
  Se   ShS'       g   SP                  SRR4      G Rj  xL
  RoMS'       g   S P                  S4      p
R\        S4      3.pVP!                  V
4       SP                  P                  S4      oS'       dJ   SP"                  P%                  SVRR	7       SP%                  VRR	7       SP'                  4       G Rj  xL
   \-        \        P                  ! 4       V	,
          4      pV'       d=   S P/                  WV4      p\1        SSS4      pS P
                  P3                  WW4       MRpRpS P                  P5                  S P                  WV4       R#  ELl ELF L  \(         dE    S P
                  P+                  R
4       S'       g   SP                  SRR4      G Rj  xL 
  Ro Li ; i  \(         d     S P
                  P+                  R4        R# i ; i   \-        \        P                  ! 4       T	,
          4      pT'       d=   S P/                  YT4      p\1        SSS4      pS P
                  P3                  YY4       MRpRpS P                  P5                  S P                  YT4       i   \(         d    S P
                  P+                  R4        i i ; i; i5i)zHandle a single HTTP/2 request with streaming support.

Streams both request and response body chunks immediately,
avoiding buffering entire uploads and enabling SSE, streaming
downloads, and other real-time use cases.
FNr  c                    <"   Se   SP                   P                  R8X  d   RR/# S'       g?   SP                  '       d-   SP                  '       g   RoSP	                  4       p RRRV RR/#  \
        P                  ! SP                  4       R	R
7      G R j  xL
 pTf   RoRRRRRR/# SP                  '       d   RoRRRTRSP                  '       * /#  L=  \
        P                   d    RR/u # i ; i5i)NCLOSEDr   r   Tr   r   r   Fr   r   r   )
r  rt   request_complete_body_chunksget_request_bodyr=   r   read_body_chunkr   _body_complete)r   r   body_receivedr?  s     r   r   3ASGIProtocol._handle_http2_request.<locals>.receive"  s     ~!2!2h!> 122 !V%<%<%<VEXEXEX $..0ND 3%..**,   } $NC  $$$ $ !6!66 % '' 3 1223sR   +C6C6C6C6.)C CC C6<C6C C30C62C33C6c                   <
"   V R ,          pVR8X  dQ   V P                  R4      pV P                  R. 4      pSP                  V4      pSP                  SW$4      G Rj  xL
  R# VR8X  d5   S'       d   \        R4      oR# RoV R,          oV P                  R. 4      oR# VR8X  Edj   S'       g   \        R	4      oR# S'       d   \        R
4      oR# V P                  RR4      pV P                  RR4      pS'       g   SP                  S4      pR\	        S4      3.pVP                  V4       SP                  P                  S4      pVf   \        R4      oR# SP                  P                  SVRR7       VP                  VRR7       SP                  4       G Rj  xL
  RoV'       d3   SP                  SWV'       * R7      G Rj  xL
  S\        V4      ,          oV'       g)   V'       g   SP                  SRRR7      G Rj  xL
  RoR# R# VR8X  dU   S'       g   \        R4      oR# V P                  R. 4      p	SP                  V	4      p
SP                  SV
4      G Rj  xL
  R# R#  EL L L Ln L5i)r   r  rg   rp   Nr  r  Tr  r  r  r   r   r   F:statuszStream closed
end_streamhttp.response.trailersz)Cannot send trailers before body complete)r  rH  send_informationalr  r!  extendstreamsrB  send_headers_send_pending_data	send_datar8  send_trailers)r  r  r  r  rp   r   r   response_hdrsr?  trailer_headerstrailersr  rB  headers_sentr  r  r  r  r  r   r@  s   &          r   r  0ASGIProtocol._handle_http2_request.<locals>.sendM  s[     vH88%kk(3&{{9b922<@00KQQQ00##/0J#KL#' ")("3#*;;y"#=  11'#/0F#GL$#/0K#LL{{63/#KKU;	 $"667GHG&/_1E%F$GM!((1 %__00;F~'3O'DOO00MV[0\''%'H!44666#'L !++It+VVV!SY.M %//	34/PPP(,%	 ! 55(#/0[#\L")++i"<33OD++Ix@@@ 6e RH 7
 W Q As   AI8I-I83;I8/I88I8=B I8I0I8,I8I2I8&I8.I8I4I8AI8$I6%	I80I82I84I86I8r  rU  TrV  r  r  )r?  r@  r[  r  _build_http2_scoper   r  rZ   r  r   r  r   r   r>  rH  r!  rZ  rB  r\  r]  r2  rb  r   _build_http2_environrm   r  r  )r   rz   rB  rf  r   r  r   r  r  r  rp   r`  r  r  r  rR  r  rc  r  r  r  r  r  r?  r@  s   f&f&&          @@@@@@@@@@r   r=  "ASGIProtocol._handle_http2_request  s     NN,,	$$Y/''8D ! )	VC	A C	AL "XX88(,	EHH  g6((54000'"" $((C9PQQQ"% "223CD"+S-A!B C$$W- ,,Y7OO00MVZ0[''$'G!44666E+DNN,<},LM%"778TG+')9=D HHOOD7I"GD%%dkk7TJQ 1 R 7 	&HH:;((C9PQQQ"%		&&  E""#CDEE+DNN,<},LM%"778TG+')9=D HHOOD7I"GD%%dkk7TJ E""#CDEs   BN$;I I I 2I I	I K I BI /I0I 5BJ% 	NI I I -J"J"JJ"K !J""K %&KNKNNBM)(N)&NNNNNc                N   . pVP                    FD  w  rVVP                  VP                  4       P                  R4      VP                  R4      34       KF  	  \	        V4      p\	        V4      pRRRRRRR/R	R
RVP
                  RVP                  RVP                  R\        VRR4      ;'       g0    VP                  '       d   VP                  P                  R4      MRRVP                  '       d   VP                  P                  R4      MRRV P                  P                  ;'       g    RRVRVRV/p	\        V P                  R4      '       d   V P                  P                  V	R&   / p
\        VR4      '       d   RVP                  RVP                   /V
R&   / V
R&   WR&   V	# )z*Build ASGI HTTP scope from HTTP/2 request.r5   r   rg  r   rf   r  r  r  r  2r  r  r  r  Nr   r  r  r  rp   r  r  r  r  r  r  r  rX  r  )rp   rs   r  r]   r&   r  r  r  r   r  r   r  r   r   r  r  r  )r   rz   rf  r   rp   rt   ru   r  r  r  r  s   &&&&       r   re  ASGIProtocol._build_http2_scope  s   "??KDNN

##I.Y'  + %X.$X. FY~u=CgnngnnGLLT:wwahamamamw||?R?RS\?]svw}}}GMM00;RU++11rwff
 4;;((![[..E'N 
7-..'11g994J/0
 02
+,(lr   c                   RVP                   RVP                  RVP                  RVP                  ;'       g    RRRRV'       d
   V^ ,          MR	/pVP                   F"  w  rVR
VP                  R	R4      ,           pWdV&   K$  	  V# )z.Build minimal environ dict for access logging.r  r  r  r  r  r  zHTTP/2r  r  r  r  )r  r  r  r  rp   r  r  s   &&&&    r   rf  !ASGIProtocol._build_http2_environ  s~     gnnw{{GMM//Rx(8A;
 #??KDDLLc22C CL + r   )r   r   r   r   r   r6  r   r   r   r   r   r   r   r   r   r   r   r   r   rA   r   r   )permit_obsolete_foldingstrip_header_spaces)F)<r   r   r   r   r   r   r   r   r   r   r   r   r   classmethodr   r  r   r  r  r  r'  r/  r+  r,  r-  r?  rG  rJ  rE  rS  rQ  rQ   rT   rc  r   rj  rm  rn  ro  r  r  r  r  r  rl  staticmethodr  r  r  r  r   r  r"  r   rH  r=  re  rf  r   r   r    s   @r   r   r   O  sh     NO"!%#' $LM< " "6'#
P>d7",
/
."$4* )$V 
/
0
&^$@-'^Q* "A8F+Z$$L5800d*6 

 

 4 4 
 
':%.N  E$N	vEp)V r   r   )&r   r=   r^  r*   rZ   gunicorn.asgi.unreaderr   gunicorn.asgi.parserr   r   r   r   r   r   gunicorn.asgi.uwsgir	   gunicorn.http.errorsr
   gunicorn.uwsgi.errorsr   r   r&   r2   re   r  r^   r[   ranger]   r  r   r7   r`   rk   rm   rx   Protocolr   )is   0r   <module>ry     s   
     0  2 + 5F F5(  4     ?DElKl1Tl)))44lK  %* %*P	%/ / j  j Zo7## oA Ls   B;