-=[ Mr. Bumblebee ]=-
_Indonesia_

Path : /usr/lib/python2.7/dist-packages/bzrlib/transport/http/
File Upload :
Current File : //usr/lib/python2.7/dist-packages/bzrlib/transport/http/response.pyc

ó
#Rc@@s™dZddlmZddlZddlZddlmZddlZddlm	Z	m
Z
defd„ƒYZdefd	„ƒYZ
d
„ZdS(s»Handlers for HTTP Responses.

The purpose of these classes is to provide a uniform interface for clients
to standard HTTP responses, single range responses and multipart range
responses.
i(tabsolute_importN(tStringIO(terrorstosutilstResponseFilecB@sVeZdZd„Zd„Zdd„Zd„Zd„Zd„Ze	j
d„ZRS(	sƒA wrapper around the http socket containing the result of a GET request.

    Only read() and seek() (forward) are supported.

    cC@s||_||_d|_dS(s„Constructor.

        :param path: File url, for error reports.

        :param infile: File-like socket set at body start.
        iN(t_patht_filet_pos(tselftpathtinfile((sB/usr/lib/python2.7/dist-packages/bzrlib/transport/http/response.pyt__init__+s		cC@sdS(s\Close this file.

        Dummy implementation for consistency with the 'file' API.
        N((R((sB/usr/lib/python2.7/dist-packages/bzrlib/transport/http/response.pytclose6siÿÿÿÿcC@s+|jj|ƒ}|jt|ƒ7_|S(s­Read size bytes from the current position in the file.

        :param size:  The number of bytes to read.  Leave unspecified or pass
            -1 to read to EOF.
        (RtreadRtlen(Rtsizetdata((sB/usr/lib/python2.7/dist-packages/bzrlib/transport/http/response.pyR
<scC@s(|jjƒ}|jt|ƒ7_|S(N(RtreadlineRR(RR((sB/usr/lib/python2.7/dist-packages/bzrlib/transport/http/response.pyRFscc@s,x%tr'|jƒ}|sdS|VqWdS(N(tTrueR(Rtline((sB/usr/lib/python2.7/dist-packages/bzrlib/transport/http/response.pyt__iter__Ks
	cC@s|jS(N(R(R((sB/usr/lib/python2.7/dist-packages/bzrlib/transport/http/response.pyttellRscC@sˆ|tjkrJ||jkr:td|j|fƒ‚n||j}n$|tjkrb|}ntdƒ‚|r„|j|ƒndS(Ns)Can't seek backwards, pos: %s, offset: %ssCan't seek backwards(tostSEEK_SETRtAssertionErrortSEEK_CURR
(Rtoffsettwhencet
to_discard((sB/usr/lib/python2.7/dist-packages/bzrlib/transport/http/response.pytseekUs	(t__name__t
__module__t__doc__RRR
RRRRRR(((sB/usr/lib/python2.7/dist-packages/bzrlib/transport/http/response.pyR%s		
			t	RangeFilecB@sŒeZdZdZdZd„Zd„Zd„Zd„Zd„Z	d	„Z
d
„Zd„Zd„Z
d
d„Zdd„Zd„ZRS(sâFile-like object that allow access to partial available data.

    All accesses should happen sequentially since the acquisition occurs during
    an http response reception (as sockets can't be seeked, we simulate the
    seek by just reading and discarding the data).

    The access pattern is defined by a set of ranges discovered as reading
    progress. Only one range is available at a given time, so all accesses
    should happen with monotonically increasing offsets.
    i iicC@s?tt|ƒj||ƒd|_d|_|jddƒdS(s„Constructor.

        :param path: File url, for error reports.

        :param infile: File-like socket set at body start.
        iiÿÿÿÿN(tsuperR!RtNonet	_boundaryt_headerst	set_range(RR	R
((sB/usr/lib/python2.7/dist-packages/bzrlib/transport/http/response.pyRƒs		cC@s"||_||_|j|_dS(sChange the range mappingN(t_startt_sizeR(RtstartR((sB/usr/lib/python2.7/dist-packages/bzrlib/transport/http/response.pyR&’s		cC@s!||_|jƒ|jƒdS(s¸Define the boundary used in a multi parts message.

        The file should be at the beginning of the body, the first range
        definition is read and taken into account.
        N(R$t
read_boundarytread_range_definition(Rtboundary((sB/usr/lib/python2.7/dist-packages/bzrlib/transport/http/response.pytset_boundary™s	
cC@s²d}x|dkr'|jjƒ}q	W|dkrOtj|j|jƒ‚n|d|jdkr®|j|ƒd|jdkr®tj|jd|j|fƒ‚q®ndS(s.Read the boundary headers defining a new ranges
ts--s'Expected a boundary (%s) line, got '%s'N(RRRtHttpBoundaryMissingRR$t_unquote_boundarytInvalidHttpResponse(Rt
boundary_line((sB/usr/lib/python2.7/dist-packages/bzrlib/transport/http/response.pyR*¤scC@s$|d tj|dd!ƒ|dS(Niiþÿÿÿ(trfc822tunquote(Rtb((sB/usr/lib/python2.7/dist-packages/bzrlib/transport/http/response.pyR0ÀscC@setj|jddƒ|_|jjddƒ}|dkrTtj|jdƒ‚n|j	|ƒdS(s·Read a new range definition in a multi parts message.

        Parse the headers including the empty line following them so that we
        are ready to read the data itself.
        tseekableis
content-ranges5Content-Range header missing in a multi-part responseN(
thttplibtHTTPMessageRR%t	getheaderR#RR1Rtset_range_from_header(Rt
content_range((sB/usr/lib/python2.7/dist-packages/bzrlib/transport/http/response.pyR+Ãsc	C@s(y|jƒ\}}Wn)tk
rAtj|j|dƒ‚nX|dkrmtj|j|d|ƒ‚nyF|jdƒ\}}|jdƒ\}}t|ƒ}t|ƒ}Wn)tk
rÞtj|j|dƒ‚nX||d}|dkrtj|j|d	ƒ‚n|j||ƒd
S(s?Helper to set the new range from its description in the headerssMalformed headertbytessUnsupported range type '%s't/t-sInvalid range valuesiisInvalid range, size <= 0N(tsplitt
ValueErrorRtInvalidHttpRangeRtintR&(	RR;trtypetvaluest	start_endttotalR)tendR((sB/usr/lib/python2.7/dist-packages/bzrlib/transport/http/response.pyR:Òs*



cC@s‹|j}|}xf|dkrw|jjt||jƒƒ}|t|ƒ8}|stj|j||||ƒ‚qqW|j|7_dS(scRead the file checking for short reads.

        The data read is discarded along the way.
        iN(	RRR
tmint_discarded_buf_sizeRRtShortReadvErrorR(RRtpost	remainingR((sB/usr/lib/python2.7/dist-packages/bzrlib/transport/http/response.pyt
_checked_readís	cC@sU|jdkr=tj|j|jd|j|jfƒ‚n|jƒ|j	ƒdS(NsRange (%s, %s) exhausted(
R$R#RtInvalidRangeRRR'R(R*R+(R((sB/usr/lib/python2.7/dist-packages/bzrlib/transport/http/response.pyt_seek_to_next_rangeüs
iÿÿÿÿcC@s‹|jdkrE|j|j|jkrE|dkr8dS|jƒnC|j|jkrˆtj|j|jd||j|jfƒ‚n|jdkrô|dkrô|j||j|jkrôtj|j|jd||j|jfƒ‚qôntƒ}|}|jdkrJ|j|j|j}|dkrJt||ƒ}qJnt	j
|j|||jƒ|j
ƒ}|jt|ƒ7_|S(såRead size bytes from the current position in the file.

        Reading across ranges is not supported. We rely on the underlying http
        client to clean the socket if we leave bytes unread. This may occur for
        the final boundary line of a multipart response or for any range
        request not entirely consumed by the client (due to offset coalescing)

        :param size:  The number of bytes to read.  Leave unspecified or pass
            -1 to read to EOF.
        iR.s)Can't read %s bytes before range (%s, %s)s)Can't read %s bytes across range (%s, %s)(R(RR'RORRNRRRHRtpumpfileRt_max_read_sizetgetvalueR(RRtbuftlimitedR((sB/usr/lib/python2.7/dist-packages/bzrlib/transport/http/response.pyR
s4
)	icC@sm|j}|dkr|}ny|dkr7||}n`|dkr‡|jdkri|j|j|}q—tj|j|jdƒ‚ntd|ƒ‚||jkrÈtj|j|jd|ƒ‚n|jdkr@|j|j}xV||kr<||j}|dkr|j|ƒn|jƒ|j|j}qêWn||j}|dkri|j|ƒndS(Niiis4RangeFile: can't seek from end while size is unknownsInvalid value %s for whence.s)RangeFile: trying to seek backwards to %s(	RR(R'RRNRR@RMRO(RRRt	start_post	final_post	cur_limittremainR((sB/usr/lib/python2.7/dist-packages/bzrlib/transport/http/response.pyR2s6		



cC@s|jS(N(R(R((sB/usr/lib/python2.7/dist-packages/bzrlib/transport/http/response.pyRXsi(RRR RIRQRR&R-R*R0R+R:RMROR
RR(((sB/usr/lib/python2.7/dist-packages/bzrlib/transport/http/response.pyR!ns
									
,&cC@s|dkrt||ƒ}nä|dkrìt||ƒ}|jddƒ}|dkrfd}t}n$|jƒdko‡|jƒdk}|r©|j|jdƒƒq|jddƒ}|dkrÜt	j
|d	ƒ‚n|j|ƒnt	j
|d
|ƒ‚|S(sDInterpret the code & headers and wrap the provided data in a RangeFile.

    This is a factory method which returns an appropriate RangeFile based on
    the code & headers it's given.

    :param url: The url being processed. Mostly for error reporting
    :param code: The integer HTTP response code
    :param msg: An HTTPMessage containing the headers for the response
    :param data: A file-like object that can be read() to get the
                 requested data
    :return: A file-like object that can seek()+read() the
             ranges indicated by the headers.
    iÈiÎscontent-typesapplication/octet-streamt	multipartt
byterangesR,s
content-ranges8Missing the Content-Range header in a 206 range responsesUnknown response code %sN(RR!R9R#tFalsetgetmaintypet
getsubtypeR-tgetparamRR1R:(turltcodetmsgRtrfiletcontent_typetis_multipartR;((sB/usr/lib/python2.7/dist-packages/bzrlib/transport/http/response.pythandle_response\s(			
(R t
__future__RRR7t	cStringIORR3tbzrlibRRtobjectRR!Re(((sB/usr/lib/python2.7/dist-packages/bzrlib/transport/http/response.pyt<module>sIî

Copyright © 2017 || Recoded By Mr.Bumblebee