ó ŸçƒQc@sÚdZddlZddlZddlZejeƒZdefd„ƒYZdej fd„ƒYZ de fd„ƒYZ d e fd „ƒYZ d e 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„Z d „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ìt|ƒ|ksòt ‚|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( RRRR RRRRRRR#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(RR t_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*R R%(((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(RR t_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 RtpositiontdatalentsplitRt block_start((sA/sys/lib/python2.7/site-packages/mercurial/httpclient/_readers.pyR%Ås8          #     (RRRR R%(((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!s   a