o
    Á¿i  ã                   @   sF   d dl Z d dlmZ d dlmZmZ G dd„ dƒZG dd„ deƒZdS )é    N)ÚRequest)ÚSocketUnreaderÚIterUnreaderc                   @   s4   e Zd ZdZdd„ Zdd„ Zdd„ Zdd	„ ZeZdS )
ÚParserNc                 C   s<   || _ t|dƒrt|ƒ| _nt|ƒ| _d | _|| _d| _d S )NÚrecvr   )ÚcfgÚhasattrr   Úunreaderr   ÚmesgÚsource_addrÚ	req_count)Úselfr   Úsourcer   © r   úH/home/ubuntu/.local/lib/python3.10/site-packages/gunicorn/http/parser.pyÚ__init__   s   


zParser.__init__c                 C   s   | S )Nr   ©r   r   r   r   Ú__iter__   s   zParser.__iter__c                 C   sR   | j r'z| j j d¡}|r| j j d¡}|sW dS W dS  tjy&   Y dS w dS )zæDiscard any unread body of the current message.

        This should be called before returning a keepalive connection to
        the poller to ensure the socket doesn't appear readable due to
        leftover body bytes.
        i   N)r
   ÚbodyÚreadÚsslÚSSLWantReadError)r   Údatar   r   r   Úfinish_body   s   ÿþûzParser.finish_bodyc                 C   sX   | j r| j  ¡ rtƒ ‚|  ¡  |  jd7  _|  | j| j| j| j¡| _ | j s)tƒ ‚| j S )Né   )	r
   Úshould_closeÚStopIterationr   r   Ú
mesg_classr   r	   r   r   r   r   r   Ú__next__.   s   zParser.__next__)	Ú__name__Ú
__module__Ú__qualname__r   r   r   r   r   Únextr   r   r   r   r      s    r   c                   @   s   e Zd ZeZdS )ÚRequestParserN)r   r    r!   r   r   r   r   r   r   r#   @   s    r#   )r   Úgunicorn.http.messager   Úgunicorn.http.unreaderr   r   r   r#   r   r   r   r   Ú<module>   s
   5