o
    h                     @   sJ   d dl Z d dlZd dlmZmZmZ dgZe de jZ	G dd dZ
dS )    N)ListOptionalUnionReceiveBuffers   
?
c                   @   s   e Zd ZdddZdeeef dd fddZdefdd	Z	de
fd
dZdefddZde
defddZde
dee fddZdee fddZdeee  fddZdefddZdS )r   returnNc                 C   s   t  | _d| _d| _d S Nr   )	bytearray_data_next_line_search_multiple_lines_searchself r   E/var/www/html/venv/lib/python3.10/site-packages/h11/_receivebuffer.py__init__0   s   
zReceiveBuffer.__init__	byteslikec                 C   s   |  j |7  _ | S N)r	   )r   r   r   r   r   __iadd__5   s   zReceiveBuffer.__iadd__c                 C   s   t t| S r   )boollenr   r   r   r   __bool__9   s   zReceiveBuffer.__bool__c                 C   
   t | jS r   )r   r	   r   r   r   r   __len__<      
zReceiveBuffer.__len__c                 C   r   r   )bytesr	   r   r   r   r   	__bytes__@   r   zReceiveBuffer.__bytes__countc                 C   s*   | j d | }| j d |= d| _d| _|S r   )r	   r
   r   r   r   outr   r   r   _extractC   s
   zReceiveBuffer._extractc                 C   s    | j d| }|sdS | |S )zB
        Extract a fixed number of bytes from the buffer.
        N)r	   r   r   r   r   r   maybe_extract_at_mostM   s   
z#ReceiveBuffer.maybe_extract_at_mostc                 C   sH   t d| jd }| jd|}|dkrt| j| _dS |d }| |S )zK
        Extract the first line, if it is completed in the buffer.
        r         
N   )maxr
   r	   findr   r   )r   search_start_indexpartial_idxidxr   r   r   maybe_extract_next_lineW   s   
z%ReceiveBuffer.maybe_extract_next_linec                 C   s   | j dd dkr| d g S | j dd dkr | d g S t| j | j}|du r9tdt| j d | _dS |dd }| |}|d}|D ]
}|	drV|d= qL|d	 |d   krfd
ksiJ  J |d	d= |S )z\
        Extract everything up to the first blank line, and return a list of lines.
        Nr!      
r$   r"   r   r#          )
r	   r   blank_line_regexsearchr   r%   r   spansplitendswith)r   matchr)   r   linesliner   r   r   maybe_extract_linesh   s(   




$
z!ReceiveBuffer.maybe_extract_linesc                 C   s&   z| j d dk W S  ty   Y dS w )Nr   !   F)r	   
IndexErrorr   r   r   r   +is_next_line_obviously_invalid_request_line   s
   z9ReceiveBuffer.is_next_line_obviously_invalid_request_line)r   N)__name__
__module____qualname__r   r   r   r   r   r   r   intr   r   r   r   r    r*   r   r7   r:   r   r   r   r   r   /   s    


+)resystypingr   r   r   __all__compile	MULTILINEr/   r   r   r   r   r   <module>   s    '