
    \Jj                     f    d dl Z d dlZd dlZd dlmZ d dlmZmZ dZ G d d      Z	 G d de	      Z
y)	    N)Request)SocketUnreaderIterUnreaderi   c                   .    e Zd ZdZd Zd ZddZd ZeZy)ParserNc                     || _         t        |d      rt        |      | _        nt	        |      | _        d | _        || _        d| _        y )Nrecvr   )cfghasattrr   unreaderr   mesgsource_addr	req_count)selfr
   sourcer   s       O/var/www/html/Extract/venv/lib/python3.12/site-packages/gunicorn/http/parser.py__init__zParser.__init__   sC    66"*62DM(0DM	&     c                     | S )N r   s    r   __iter__zParser.__iter__#   s    r   c                    | j                   sy||t        }t        | j                  dd      }|+t	        |d      rt	        |d      r|}|j                         }nd}d}d}	 	 |F|D|t        j                         z
  }|dk  r	 |	 |j                  |       yy|j                  |       	 | j                   j                  j                  d      }|s	 |	 |j                  |       yy|t#        |      z  }|||k\  r	 |	 |j                  |       yy# t        $ r Y yw xY w# t        j                  t        f$ r' Y |"	 |j                  |       y# t        $ r Y yw xY wyt        j                   $ r' Y |"	 |j                  |       y# t        $ r Y yw xY wyw xY w# t        $ r Y yw xY w# t        $ r Y yw xY w# |"	 |j                  |       w # t        $ r Y w w xY ww xY w)	a<  Discard any unread body of the current message.

        Called before returning a keepalive connection to the poller so the
        socket does not appear readable due to leftover body bytes.

        ``deadline`` is an absolute ``time.monotonic()`` value; when set the
        socket read timeout is bounded by the remaining time before each read.
        ``max_bytes`` caps the total drained bytes; when a deadline is given
        and ``max_bytes`` is left at the default, ``_DRAIN_MAX_BYTES`` applies
        to defend against a slow client that keeps trickling under it.  When
        called without a deadline (the default invocation from ``__next__``),
        no byte cap is applied so the prior unbounded drain semantics are
        preserved for callers that don't know how to react to a partial drain.

        Returns ``True`` when the body was fully drained, ``False`` when the
        drain was abandoned (deadline, byte cap, or socket timeout).  Callers
        that observe ``False`` MUST close the connection rather than serve
        another request on it.
        TNsock
gettimeout
settimeoutr   Fi   )r   _DRAIN_MAX_BYTESgetattrr   r   r   time	monotonicr   OSErrorbodyreadsockettimeoutTimeoutErrorsslSSLWantReadErrorlen)	r   deadline	max_bytesr   timeoutable_sockprior_timeoutdrained	remainingdatas	            r   finish_bodyzParser.finish_body&   sP   ( yy!5(It}}fd3 l ;l@[# OO-M# M	',<,H (4>>+; ;I A~$  +$//> , %//	: 99>>..t4D 
  +$//> ,	 3t9$(W	-A +$//> ,' ,   5 !   +$//>  , ++    +$//>  ,   w   +$//>  ,s   #!G  D G  -%D' G  F" +G  F1 G  	D$#D$'F G  E 	E"!E"&F8G  <F 	FFFG  "	F.-F.1	F=<F= G&GG&	G"G&!G""G&c                 r   | j                   r$| j                   j                         r
t               | j                          | xj                  dz  c_        | j                  | j                  | j                  | j                  | j                        | _         | j                   s
t               | j                   S )N   )	r   should_closeStopIterationr1   r   
mesg_classr
   r   r   r   s    r   __next__zParser.__next__e   s    99//1/! 	 	!OODHHdmmT=M=Mt~~^	yy/!yyr   )NN)	__name__
__module____qualname__r6   r   r   r1   r7   nextr   r   r   r   r      s#    J
=~ Dr   r   c                       e Zd ZeZy)RequestParserN)r8   r9   r:   r   r6   r   r   r   r=   r=   w   s    Jr   r=   )r$   r'   r   gunicorn.http.messager   gunicorn.http.unreaderr   r   r   r   r=   r   r   r   <module>r@      s7   
  
  ) ?  a aHF r   