+
    j                     &    R t ^ RIt ! R R4      tR# )zt
Async version of gunicorn/http/unreader.py for ASGI workers.

Provides async reading with pushback buffer support.
Nc                   \   a  ] tR t^t o RtRR ltR tR tR tRR lt	R t
R	 tR
 tRtV tR# )AsyncUnreadera$  Async socket reader with pushback buffer support.

This class wraps an asyncio StreamReader and provides the ability
to "unread" data back into a buffer for re-parsing.

Performance optimization: Reuses BytesIO buffer with truncate/seek
instead of creating new objects to reduce GC pressure.
c                `    Wn         \        P                  ! 4       V n        W n        ^ V n        R# )z}Initialize the async unreader.

Args:
    reader: asyncio.StreamReader instance
    max_chunk: Maximum bytes to read at once
N)readerioBytesIObuf	max_chunk
_buf_start)selfr   r	   s   &&&K/var/www/idalgo/venv/lib/python3.14/site-packages/gunicorn/asgi/unreader.py__init__AsyncUnreader.__init__   s"     ::<"    c                    V P                   P                  ^ 4       V P                   P                  ^ 4       ^ V n        R# )z7Reset buffer for reuse instead of creating new BytesIO.N)r   seektruncater
   r   s   &r   _reset_bufferAsyncUnreader._reset_buffer$   s+    a!r   c                    V P                   P                  V P                  4       V P                   P                  4       pV P	                  4        V# )z'Get all buffered data and reset buffer.)r   r   r
   readr   )r   datas   & r   _get_buffered_data AsyncUnreader._get_buffered_data*   s6    doo&xx}}r   c                z    V P                   P                  ^ \        P                  4      pWP                  ,
          # )zGet size of buffered data.)r   r   r   SEEK_ENDr
   )r   ends   & r   _buffer_sizeAsyncUnreader._buffer_size1   s'    hhmmAr{{+__$$r   Nc                  "   Ve"   \        V\        4      '       g   \        R4      hVe   V^ 8X  d   R# V^ 8  d   RpV P                  4       pVf   V^ 8  d   V P	                  4       # Vf   V P                  4       G Rj  xL
 pV# W!8  d   V P                  4       G Rj  xL
 pV'       g   V P	                  4       # V P                  P                  ^ \        P                  4       V P                  P                  V4       V\        V4      ,          pK  V P                  P                  V P                  4       V P                  P                  V4      pV ;P                  V,          un        V P                  R8  dN   V P                  P                  4       pV P                  4        V'       d   V P                  P                  V4       V#  ELO EL25i)zRead data from the stream, using buffered data first.

Args:
    size: Number of bytes to read. If None, returns all buffered
          data or reads a single chunk.

Returns:
    bytes: Data read from buffer or stream
Nz&size parameter must be an int or long.r       )
isinstanceint	TypeErrorr   r   _read_chunkr   r   r   r   writelenr
   r   r   )r   sizebuf_sizechunkr   	remainings   &&    r   r   AsyncUnreader.read6   sg     JtS$9$9DEEqyax$$& <HqL**,,<**,,EL o**,,E..00HHMM!R[[)HHNN5!E
"H 	doo&xx}}T" 	4 ??T!I y)5 -
 -s1   A>G GG G!G-DG2GGc                   "    V P                   P                  V P                  4      G Rj  xL
 #  L  \         d     R# i ; i5i)z0Read a chunk of data from the underlying stream.Nr   )r   r   r	   	Exceptionr   s   &r   r%   AsyncUnreader._read_chunkk   s:     	))$..9999 		s0   A(3 13 A3 AAAAc                8   V'       d   V P                   P                  V P                  4       V P                   P                  4       pV P	                  4        V P                   P                  V4       V'       d   V P                   P                  V4       R# R# R# )zPush data back into the buffer for re-reading.

Args:
    data: bytes to push back

Note: This prepends data to the buffer so it will be read first.
N)r   r   r
   r   r   r&   )r   r   existings   && r   unreadAsyncUnreader.unreadr   se     HHMM$//*xx}}H  HHNN4 x(  r   c                (    V P                  4       ^ 8  # )z-Check if there's data in the pushback buffer.)r   r   s   &r   has_buffered_dataAsyncUnreader.has_buffered_data   s      "Q&&r   )r
   r   r	   r   )r!   )N)__name__
__module____qualname____firstlineno____doc__r   r   r   r   r   r%   r2   r5   __static_attributes____classdictcell__)__classdict__s   @r   r   r      s8     
%
3j)&' 'r   r   )r;   r   r    r   r   <module>r@      s   
 
y' y'r   