MOON
Server: Apache
System: Linux server30c.hostingraja.org 3.10.0-962.3.2.lve1.5.63.el7.x86_64 #1 SMP Fri Oct 8 12:03:35 UTC 2021 x86_64
User: jibhires (1887)
PHP: 8.1.30
Disabled: show_source, system, shell_exec, passthru, exec, popen, proc_open, allow_url_fopen, symlink, escapeshellcmd, pcntl_exec
Upload Files
File: //opt/alt/python35/lib64/python3.5/site-packages/aiohttp/__pycache__/streams.cpython-35.opt-1.pyc


���Z?A�@sddlZddlZddlmZmZddlmZddddd	fZd
dZGdd�de	�Z
Gd
d�d�ZGdd�de�ZGdd�d�Z
Gdd�de
�ZGdd�de
�Ze�ZGdd�d�ZGdd	�d	e�ZdS)�N�)�
set_exception�
set_result)�internal_logger�
EMPTY_PAYLOAD�	EofStream�StreamReader�	DataQueue�FlowControlDataQueue��c@seZdZdZdS)rzeof stream indication.N)�__name__�
__module__�__qualname__�__doc__�rr�/streams.pyrsc@s4eZdZdd�Zdd�Zdd�ZdS)�AsyncStreamIteratorcCs
||_dS)N)�	read_func)�selfrrrr�__init__szAsyncStreamIterator.__init__cCs|S)Nr)rrrr�	__aiter__szAsyncStreamIterator.__aiter__c�sFy|j�IdH}Wntk
r/t�YnX|dkrBt�|S)N�)rr�StopAsyncIteration)r�rvrrr�	__anext__s
zAsyncStreamIterator.__anext__N)r
rrrrrrrrrrsrc@seZdZdd�ZdS)�ChunkTupleAsyncStreamIteratorc�s'|j�IdH}|dkr#t�|S)NrF)rF)rr)rrrrrr&sz'ChunkTupleAsyncStreamIterator.__anext__N)r
rrrrrrrr%src@s@eZdZdd�Zdd�Zdd�Zdd�Zd	S)
�AsyncStreamReaderMixincCs
t|j�S)N)r�readline)rrrrr/sz AsyncStreamReaderMixin.__aiter__cst��fdd��S)zzReturns an asynchronous iterator that yields chunks of size n.

        Python-3.5 available for Python 3.5+ only
        cs
�j��S)N)�readr)�nrrr�<lambda>7sz5AsyncStreamReaderMixin.iter_chunked.<locals>.<lambda>)r)rr r)r rr�iter_chunked2sz#AsyncStreamReaderMixin.iter_chunkedcCs
t|j�S)z�Returns an asynchronous iterator that yields all the available
        data as soon as it is received

        Python-3.5 available for Python 3.5+ only
        )r�readany)rrrr�iter_any9szAsyncStreamReaderMixin.iter_anycCs
t|j�S)a
Returns an asynchronous iterator that yields chunks of data
        as they are received by the server. The yielded objects are tuples
        of (bytes, bool) as returned by the StreamReader.readchunk method.

        Python-3.5 available for Python 3.5+ only
        )r�	readchunk)rrrr�iter_chunksAsz"AsyncStreamReaderMixin.iter_chunksN)r
rrrr"r$r&rrrrr-src@s?eZdZdZdZdedddddd�Zd	d
�Zdd�Zd
d�Z	dd�Z
dd�Zdd�Zdd�Z
dd�Zdd�Zddd�Zdd�Zdd �Zd!d"�Zd#d$�Zd4d&d'�Zd(d)�Zd*d+�Zd,d-�Zd5d.d/�Zd0d1�Zd2d3�ZdS)6ra*An enhancement of asyncio.StreamReader.

    Supports asynchronous iteration by line, chunk or as available::

        async for line in reader:
            ...
        async for chunk in reader.iter_chunked(1024):
            ...
        async for slice in reader.iter_any():
            ...

    r�limit�timerN�loopcCs�||_||_|d|_|dkr7tj�}||_d|_d|_d|_t	j
�|_d|_d|_
d|_d|_d|_||_g|_dS)NrrF)�	_protocol�
_low_water�_high_water�asyncioZget_event_loop�_loop�_size�_cursor�_http_chunk_splits�collections�deque�_buffer�_buffer_offset�_eof�_waiter�_eof_waiter�
_exception�_timer�_eof_callbacks)r�protocolr'r(r)rrrr[s"		
										zStreamReader.__init__cCs�|jjg}|jr,|jd|j�|jrB|jd�|jtkrn|jd|j|jf�|jr�|jd|j�|j	r�|jd|j	�ddj
|�S)Nz%d bytes�eofzlow=%d high=%dzw=%rze=%rz<%s>� )�	__class__r
r/�appendr6r+�
DEFAULT_LIMITr,r7r9�join)r�inforrr�__repr__os		
		zStreamReader.__repr__cCs|jS)N)r9)rrrr�	exception}szStreamReader.exceptioncCsp||_|jj�|j}|dk	rAd|_t||�|j}|dk	rlt||�d|_dS)N)r9r;�clearr7rr8)r�exc�waiterrrrr�s	
		
	
zStreamReader.set_exceptioncCsM|jr9y|�WqItk
r5tjd�YqIXn|jj|�dS)NzException in eof callback)r6�	ExceptionrrEr;r@)r�callbackrrr�on_eof�s	
zStreamReader.on_eofcCs�d|_|j}|dk	r4d|_t|d�|j}|dk	r_d|_t|d�x>|jD]3}y|�Wqitk
r�tjd�YqiXqiW|jj�dS)NTzException in eof callback)	r6r7rr8r;rIrrErF)rrH�cbrrr�feed_eof�s			
		

zStreamReader.feed_eofcCs|jS)z&Return True if  'feed_eof' was called.)r6)rrrr�is_eof�szStreamReader.is_eofcCs|jo|jS)z=Return True if the buffer is empty and 'feed_eof' was called.)r6r4)rrrr�at_eof�szStreamReader.at_eofc�s@|jr
dS|jj�|_z|jIdHWdd|_XdS)N)r6r.�
create_futurer8)rrrr�wait_eof�s	zStreamReader.wait_eofcCs�|s
dS|jr=|jd|jd�|jd<d|_|jt|�7_|jt|�8_|jj|�d|_dS)zN rollback reading some data from stream, inserting it to buffer head.
        Nr)r5r4r/�lenr0�
appendleftZ_eof_counter)r�datarrr�unread_data�s	!	zStreamReader.unread_datacCs�|s
dS|jt|�7_|jj|�|jt|�7_|j}|dk	rod|_t|d�|j|jkr�|jj	r�|jj
�dS)NF)r/rRr4r@�total_bytesr7rr,r*�_reading_paused�
pause_reading)rrT�sizerHrrr�	feed_data�s		

zStreamReader.feed_datacCs|jdkrg|_dS)N)r1)rrrr�begin_http_chunk_receiving�sz'StreamReader.begin_http_chunk_receivingcCsR|jdkrtd��|js;|jd|jkrN|jj|j�dS)NzFCalled end_chunk_receiving without calling begin_chunk_receiving firstr���)r1�RuntimeErrorrVr@)rrrr�end_http_chunk_receiving�s

z%StreamReader.end_http_chunk_receivingc�sy|jdk	rtd|��|jj�}|_z3|jr^|j�|IdHWdQRXn	|IdHWdd|_XdS)NzH%s() called while another coroutine is already waiting for incoming data)r7r]r.rPr:)r�	func_namerHrrr�_wait�s
	

zStreamReader._waitc�s|jdk	r|j�g}d}d}x�|r�x�|jr�|r�|j}|jdjd|�d}|j|r�||nd	�}|j|�|t|�7}|r�d}||jkr6td��q6W|j	r�P|r-|j
d�IdHq-Wdj|�S)
NrTs
rFzLine is too longrrr\)r9r4r5�find�_read_nowait_chunkr@rRr,�
ValueErrorr6r`rB)r�lineZ	line_sizeZ
not_enough�offsetZicharrTrrrrs*			
	zStreamReader.readlinerc�s�|jdk	r|j�|s"dS|dkrmg}x)|j�IdH}|sOP|j|�q7Wdj|�S|jr�|jr�|jd�IdH|j|�S)Nrrr)r9r#r@rBr4r6r`�_read_nowait)rr �blocks�blockrrrrs	
zStreamReader.readc�sK|jdk	r|j�|jr>|jr>|jd�IdH|jd�S)Nr#rr\)r9r4r6r`rf)rrrrr#Cs
	zStreamReader.readanyc�s|jdk	r|j�|jrw|jrw|jre|j|jdkre|jdd�|_dS|jd�IdH|js�d	S|jdk	rxY|jr�|jd}|jdd�|_||jkr�|j||j�dfSq�W|jd
�dfS|jd�dfSdS)z�Returns a tuple of (data, end_of_http_chunk). When chunked transfer
        encoding is used, end_of_http_chunk is a boolean indicating if the end
        of the data corresponds to the end of a HTTP chunk , otherwise it is
        always False.
        NrrrTr%F)rT)rFr\r\)r9r4r6r1r0r`rfrb)r�posrrrr%Ls$			
zStreamReader.readchunkc�s�|jdk	r|j�g}xu|dkr�|j|�IdH}|sudj|�}tjj|t|�|��|j|�|t|�8}q!Wdj|�S)Nrr)r9rrBr-�streams�IncompleteReadErrorrRr@)rr rgrh�partialrrr�readexactlyjs		
zStreamReader.readexactlycCsJ|jdk	r|j�|jr=|jj�r=td��|j|�S)Nz9Called while some coroutine is waiting for incoming data.)r9r7�doner]rf)rr rrr�read_nowaitzs		zStreamReader.read_nowaitcCs�|jd}|j}|dkr^t|�||kr^||||�}|j|7_n>|r�|jj�||d�}d|_n|jj�}|jt|�8_|jt|�7_|j|jkr�|jjr�|jj	�|S)Nrrr\)
r4r5rR�popleftr/r0r+r*rW�resume_reading)rr Zfirst_bufferrerTrrrrb�s
	"

zStreamReader._read_nowait_chunkcCsrg}xR|jrZ|j|�}|j|�|dkr	|t|�8}|dkr	Pq	W|rndj|�SdS)Nrrrr\)r4rbr@rRrB)rr Zchunks�chunkrrrrf�s
zStreamReader._read_nowaitr\r\)r
rrrrVrArrDrErrKrMrNrOrQrUrZr[r^r`rrr#r%rmrorbrfrrrrrKs2	%	c@s�eZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dd�Z
dd�Zddd�Zdd�Z
dd�Zdd�Zdd�ZdS) �EmptyStreamReadercCsdS)Nr)rrrrrE�szEmptyStreamReader.exceptioncCsdS)Nr)rrGrrrr�szEmptyStreamReader.set_exceptioncCs1y|�Wntk
r,tjd�YnXdS)NzException in eof callback)rIrrE)rrJrrrrK�s
zEmptyStreamReader.on_eofcCsdS)Nr)rrrrrM�szEmptyStreamReader.feed_eofcCsdS)NTr)rrrrrN�szEmptyStreamReader.is_eofcCsdS)NTr)rrrrrO�szEmptyStreamReader.at_eofc�sdS)Nr)rrrrrQ�szEmptyStreamReader.wait_eofcCsdS)Nr)rrTrrrrZ�szEmptyStreamReader.feed_datac�sdS)Nrr)rrrrr�szEmptyStreamReader.readlinerc�sdS)Nrr)rr rrrr�szEmptyStreamReader.readc�sdS)Nrr)rrrrr#�szEmptyStreamReader.readanyc�sdS)NrF)rFr)rrrrr%�szEmptyStreamReader.readchunkc�stjjd|��dS)Nr)r-rjrk)rr rrrrm�szEmptyStreamReader.readexactlycCsdS)Nrr)rrrrro�szEmptyStreamReader.read_nowaitNr\)r
rrrErrKrMrNrOrQrZrrr#r%rmrorrrrrs�srsc@s�eZdZdZdddd�Zdd�Zdd	�Zd
d�Zdd
�Zdd�Z	ddd�Z
dd�Zdd�Zdd�Z
dS)r	z>DataQueue is a general-purpose blocking queue with one reader.r)NcCs@||_d|_d|_d|_d|_tj�|_dS)NFr)r.r6r7r9r/r2r3r4)rr)rrrr�s					zDataQueue.__init__cCs
t|j�S)N)rRr4)rrrr�__len__�szDataQueue.__len__cCs|jS)N)r6)rrrrrN�szDataQueue.is_eofcCs|jo|jS)N)r6r4)rrrrrO�szDataQueue.at_eofcCs|jS)N)r9)rrrrrE�szDataQueue.exceptioncCsAd|_||_|j}|dk	r=t||�d|_dS)NT)r6r9r7r)rrGrHrrrr�s			
zDataQueue.set_exceptionrcCsT|j|7_|jj||f�|j}|dk	rPd|_t|d�dS)NT)r/r4r@r7r)rrTrYrHrrrrZ�s		zDataQueue.feed_datacCs8d|_|j}|dk	r4d|_t|d�dS)NTF)r6r7r)rrHrrrrMs
			zDataQueue.feed_eofc�s�|jrc|jrc|jj�|_y|jIdHWn*tjtjfk
rbd|_�YnX|jr�|jj�\}}|j	|8_	|S|j
dk	r�|j
�nt�dS)N)r4r6r.rPr7r-�CancelledError�TimeoutErrorrpr/r9r)rrTrYrrrrs		zDataQueue.readcCs
t|j�S)N)rr)rrrrr$szDataQueue.__aiter__)r
rrrrrtrNrOrErrZrMrrrrrrr	�s		csXeZdZdZdedd�fdd�Z�fdd�Z�fd	d
�Z�S)r
zgFlowControlDataQueue resumes and pauses an underlying stream.

    It is a destination for parsed data.r'r)Ncs-t�jd|�||_|d|_dS)Nr)r)�superrr*�_limit)rr<r'r))r?rrr-s	zFlowControlDataQueue.__init__csCt�j||�|j|jkr?|jjr?|jj�dS)N)rwrZr/rxr*rWrX)rrTrY)r?rrrZ3szFlowControlDataQueue.feed_datac�sIzt�j�IdHSWd|j|jkrD|jjrD|jj�XdS)N)rwrr/rxr*rWrq)r)r?rrr9szFlowControlDataQueue.read)r
rrrrArrZrrr)r?rr
(s)r-r2Zhelpersrr�logr�__all__rArIrrrrrrsrr	r
rrrr�<module>s 	
�b0	I