Plan 9 from Bell Labs’s /usr/web/sources/contrib/jas/root/sys/lib/python2.7/site-packages/mercurial/httpclient/_readers.pyc

Copyright © 2021 Plan 9 Foundation.
Distributed under the MIT License.
Download the Plan 9 distribution.


��c@s�dZddlZddlZddlZeje�Zdefd��YZdej	fd��YZ
defd��YZd	efd
��YZ
de
fd��YZd
e
fd��YZdefd��YZdS(s�Reader objects to abstract out different body response types.

This module is package-private. It is not expected that these will
have any clients outside of httpplus.
i�NtReadNotReadycBseZdZRS(s>Raised when read() is attempted but not enough data is loaded.(t__name__t
__module__t__doc__(((sA/sys/lib/python2.7/site-packages/mercurial/httpclient/_readers.pyR*stHTTPRemoteClosedErrorcBseZdZRS(s@The server closed the remote socket in the middle of a response.(RRR(((sA/sys/lib/python2.7/site-packages/mercurial/httpclient/_readers.pyR.stAbstractReadercBsbeZdZd�Zd�Zd�Zd�Zd�Zd�Zd
d�Z
d�Zd	�ZRS(s�Abstract base class for response readers.

    Subclasses must implement _load, and should implement _close if
    it's not an error for the server to close their socket without
    some termination condition being detected during _load.
    cCst|_g|_d|_dS(Ni(tFalset	_finishedt_done_chunkstavailable_data(tself((sA/sys/lib/python2.7/site-packages/mercurial/httpclient/_readers.pyt__init__9s		cCs)|jj|�|jt|�7_dS(N(RtappendR	tlen(R
tdata((sA/sys/lib/python2.7/site-packages/mercurial/httpclient/_readers.pytaddchunk>scCs,|jjd|�|jt|�7_dS(Ni(RtinsertR	R
(R
R((sA/sys/lib/python2.7/site-packages/mercurial/httpclient/_readers.pyt	pushchunkBscCs+|jjd�}|jt|�8_|S(Ni(RtpopR	R
(R
tb((sA/sys/lib/python2.7/site-packages/mercurial/httpclient/_readers.pytpopchunkFscCs|jS(N(R(R
((sA/sys/lib/python2.7/site-packages/mercurial/httpclient/_readers.pytdoneLscCs�|j|kr%|jr%t��ng}|}x||jr�|j�}t|�|kr|| }|j||�|}n|j|�|t|�8}|dkr4Pq4q4Wdj|�}t|�|ks�jr�|�|ks��|S(Nit(
R	RRRRR
RRtjointAssertionError(R
tamttblockstneedRtnbtresult((sA/sys/lib/python2.7/site-packages/mercurial/httpclient/_readers.pytreadOs"
	
3cCs�|dkrg}nx�|jr�|j�}|j|�t|�}|r�|t|�krr|j||�n|j|| �Pq|j|�qW|S(sdreturn available data chunks up to the first one in which delimstr
        occurs. No data will be returned after delimstr -- the chunk in which
        it occurs will be split and the remainder pushed back onto the available
        data queue. If blocks is supplied chunks will be added to blocks, otherwise
        a new list will be allocated.
        N(tNoneRRtfindR
RR(R
tdelimstrRRti((sA/sys/lib/python2.7/site-packages/mercurial/httpclient/_readers.pytreadtocs	cCs
t�dS(s5Subclasses must implement this.

        As data is available to be read out of this object, it should
        be placed into the _done_chunks list. Subclasses should not
        rely on data remaining in _done_chunks forever, as it may be
        reaped if the client is parsing data as it comes in.
        N(tNotImplementedError(R
R((sA/sys/lib/python2.7/site-packages/mercurial/httpclient/_readers.pyt_loadzscCs|jstd��ndS(s�Default implementation of close.

        The default implementation assumes that the reader will mark
        the response as finished on the _finished attribute once the
        entire response body has been read. In the event that this is
        not true, the subclass should override the implementation of
        close (for example, close-is-end responses have to set
        self._finished in the close handler.)
        s5server appears to have closed the socket mid-responseN(RR(R
((sA/sys/lib/python2.7/site-packages/mercurial/httpclient/_readers.pyt_close�s
	N(
RRRRRRRRRRR#R%R&(((sA/sys/lib/python2.7/site-packages/mercurial/httpclient/_readers.pyR2s							
tAbstractSimpleReadercBseZdZd�ZRS(s�Abstract base class for simple readers that require no response decoding.

    Examples of such responses are Connection: Close (close-is-end)
    and responses that specify a content length.
    cCsP|r#|js#td|��ntjd|jt|��|j|�dS(Ns*tried to add data (%r) to a closed reader!s%s read an additional %d data(RRtloggertdebugtnameR
R(R
R((sA/sys/lib/python2.7/site-packages/mercurial/httpclient/_readers.pyR%�s

(RRRR%(((sA/sys/lib/python2.7/site-packages/mercurial/httpclient/_readers.pyR'�stCloseIsEndReadercBseZdZdZd�ZRS(s?Reader for responses that specify Connection: Close for length.sclose-is-endcCstjd�t|_dS(Ns&Marking close-is-end reader as closed.(R(tinfotTrueR(R
((sA/sys/lib/python2.7/site-packages/mercurial/httpclient/_readers.pyR&�s
(RRRR*R&(((sA/sys/lib/python2.7/site-packages/mercurial/httpclient/_readers.pyR+�stContentLengthReadercBs&eZdZdZd�Zd�ZRS(s:Reader for responses that specify an exact content length.scontent-lengthcCs;tj|�||_|dkr.t|_nd|_dS(Ni(RRt_amountR-Rt_amount_seen(R
tamount((sA/sys/lib/python2.7/site-packages/mercurial/httpclient/_readers.pyR�s

	cCsTtj||�|jt|�7_|j|jkrPt|_tjd�ndS(Nscontent-length read complete(	R'R%R0R
R/R-RR(R)(R
R((sA/sys/lib/python2.7/site-packages/mercurial/httpclient/_readers.pyR%�s
	(RRRR*RR%(((sA/sys/lib/python2.7/site-packages/mercurial/httpclient/_readers.pyR.�s	t
ChunkedReadercBs eZdZd�Zd�ZRS(s/Reader for chunked transfer encoding responses.cCs,tj|�||_d|_d|_dS(NiR(RRt_eolt_leftover_skip_amtt_leftover_data(R
teol((sA/sys/lib/python2.7/site-packages/mercurial/httpclient/_readers.pyR�s
		cCs�|jstd��tjdt|��d}|jrstjd�|j|}|j}d|_d|_nt|�}x||kr�|j|j|�}|dkr�||_||_dSt	|||!dd�}|t|j�}||t|j�t|�kr*||_||_dS|dkrPt
|_tjd	�dS|j||||!�||t|j�}q�WdS(
Ns%tried to add data to a closed reader!s"chunked read an additional %d datais8chunked reader trying to finish block from leftover dataRi�tbaseis/closing chunked reader due to chunk of length 0(RRR(R)R
R5R4R R3tintR-R(R
RtpositiontdatalentsplitRtblock_start((sA/sys/lib/python2.7/site-packages/mercurial/httpclient/_readers.pyR%�s8	

				#			
(RRRRR%(((sA/sys/lib/python2.7/site-packages/mercurial/httpclient/_readers.pyR2�s	(Rthttplibt	itertoolstloggingt	getLoggerRR(t	ExceptionRt
HTTPExceptionRtobjectRR'R+R.R2(((sA/sys/lib/python2.7/site-packages/mercurial/httpclient/_readers.pyt<module>!sa	

Bell Labs OSI certified Powered by Plan 9

(Return to Plan 9 Home Page)

Copyright © 2021 Plan 9 Foundation. All Rights Reserved.
Comments to webmaster@9p.io.