ó
    G‘iA  ã                   ó$   • S r SSKr " S S5      rg)zt
Async version of gunicorn/http/unreader.py for ASGI workers.

Provides async reading with pushback buffer support.
é    Nc                   ó>   • \ rS rSrSrS
S jrSS jrS rS rS r	S	r
g)ÚAsyncUnreaderé   z©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.
c                 óP   • Xl         [        R                  " 5       U l        X l        g)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)Úselfr   r   s      Ú`/var/www/fortnox.synktek.com/backend/venv/lib/python3.13/site-packages/gunicorn/asgi/unreader.pyÚ__init__ÚAsyncUnreader.__init__   s   € ð ŒÜ—:’:“<ˆŒØ"ó    Nc              ƒ   óÄ  #   • Ub   [        U[        5      (       d  [        S5      eUb  US:X  a  gUS:  a  SnU R                  R	                  S[
        R                  5        UcU  U R                  R                  5       (       a6  U R                  R                  5       n[
        R                  " 5       U l        U$ Uc  U R                  5       I Sh  v•N nU$ U R                  R                  5       U:  a  U R                  5       I Sh  v•N nU(       d6  U R                  R                  5       n[
        R                  " 5       U l        U$ U R                  R                  U5        U R                  R                  5       U:  a  M  U R                  R                  5       n[
        R                  " 5       U l        U R                  R                  XAS 5        USU $  GN NÕ7f)zÛRead 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   r   )Ú
isinstanceÚintÚ	TypeErrorr
   Úseekr   ÚSEEK_ENDÚtellÚgetvaluer	   Ú_read_chunkÚwrite)r   ÚsizeÚretÚchunkÚdatas        r   ÚreadÚAsyncUnreader.read    sh  é € ð Ñ¤J¨t´S×$9Ñ$9ÜÐDÓEÐEàÑØq‹yØØa‹xØð 	‰‰aœŸ™Ô%ð ‰<˜DŸH™HŸM™MŸO™OØ—(‘(×#Ñ#Ó%ˆCÜ—z’z“|ˆDŒHØˆJØ‰<Ø×*Ñ*Ó,×,ˆEØˆLð h‰hm‰m‹o Ó$Ø×*Ñ*Ó,×,ˆEÞØ—h‘h×'Ñ'Ó)ÜŸ:š:›<”Ø
ØH‰HN‰N˜5Ô!ð h‰hm‰m‹o Õ$ð x‰x× Ñ Ó"ˆÜ—:’:“<ˆŒØ‰‰t˜E{Ô#ØETˆ{Ðò -ñ
 -ùs,   ‚CG ÃGÃ7G ÄGÄ	A:G ÆAG ÇG c              ƒ   óŠ   #   •  U R                   R                  U R                  5      I Sh  v•N $  N! [         a     gf = f7f)z0Read a chunk of data from the underlying stream.Nr   )r   r   r   Ú	Exception)r   s    r   r   ÚAsyncUnreader._read_chunkM   s:   é € ð	ØŸ™×)Ñ)¨$¯.©.Ó9×9Ð9Ñ9øÜó 	Ùð	üs/   ‚A„(3 ¬1­3 °A±3 ³
A ½A¿A Á Ac                 óž   • U(       aF  U R                   R                  S[        R                  5        U R                   R	                  U5        gg)zSPush data back into the buffer for re-reading.

Args:
    data: bytes to push back
r   N)r
   r   r   r   r   )r   r   s     r   ÚunreadÚAsyncUnreader.unreadT   s2   € ö ØH‰HM‰M˜!œRŸ[™[Ô)ØH‰HN‰N˜4Õ ð r   c                 óþ   • U R                   R                  5       nU R                   R                  S[        R                  5        U R                   R                  5       S:„  nU R                   R                  U5        U$ )z-Check if there's data in the pushback buffer.r   )r
   r   r   r   r   )r   ÚposÚhas_datas      r   Úhas_buffered_dataÚAsyncUnreader.has_buffered_data^   sP   € àh‰hm‰m‹oˆØ‰‰aœŸ™Ô%Ø—8‘8—=‘=“? QÑ&ˆØ‰‰cÔØˆr   )r
   r   r   )i    )N)Ú__name__Ú
__module__Ú__qualname__Ú__firstlineno__Ú__doc__r   r   r   r%   r*   Ú__static_attributes__© r   r   r   r      s!   † ñô	#ô+òZò!õr   r   )r0   r   r   r2   r   r   Ú<module>r3      s   ðñ
ó 
÷Vò Vr   