ó FuÚ_c@s¼ddlZddlZddlmZddlmZddlmZmZm Z ddl m Z m Z ddl m ZddlmZejeƒZdefd „ƒYZd „ZdS( iÿÿÿÿN(t ScalarTypes(tfirst_non_none_response(tjsontset_socket_timeoutt XMLParseError(tIncompleteReadErrortReadTimeoutError(R(tparserst StreamingBodycBsweZdZdZd„Zd„Zd d„Zd„Zd„Z e Z de d„Z ed„Z d „Zd „ZRS( seWrapper class for an http response body. This provides a few additional conveniences that do not exist in the urllib3 model: * Set the timeout on the socket (i.e read() timeouts) * Auto validation of content length, if the amount of bytes we read does not match the content length, an exception is raised. icCs||_||_d|_dS(Ni(t _raw_streamt_content_lengtht _amount_read(tselft raw_streamtcontent_length((s</opt/awscli/lib/python2.7/site-packages/botocore/response.pyt__init__+s  cCsByt|j|ƒWn'tk r=tjddtƒ‚nXdS(s&Set the timeout seconds on the socket.sbCannot access the socket object of a streaming response. It's possible the interface has changed.texc_infoN(RR tAttributeErrortloggerterrortTrue(R ttimeout((s</opt/awscli/lib/python2.7/site-packages/botocore/response.pyR0s   cCs‰y|jj|ƒ}Wn+tk rC}td|jd|ƒ‚nX|jt|ƒ7_|dksx| r…|dkr…|jƒn|S(shRead at most amt bytes from the stream. If the amt argument is omitted, read all data. t endpoint_urlRiN( R treadtURLLib3ReadTimeoutErrorRturlR tlentNonet_verify_content_length(R tamttchunkte((s</opt/awscli/lib/python2.7/site-packages/botocore/response.pyRGs cCs|j|jƒS(sCReturn an iterator to yield 1k chunks from the raw stream. (t iter_chunkst_DEFAULT_CHUNK_SIZE(R ((s</opt/awscli/lib/python2.7/site-packages/botocore/response.pyt__iter__YscCs)|j|jƒ}|r|Stƒ‚dS(s6Return the next 1k chunk from the raw stream. N(RR!t StopIteration(R t current_chunk((s</opt/awscli/lib/python2.7/site-packages/botocore/response.pyt__next__^sccsƒd}x[|j|ƒD]J}||jtƒ}x$|d D]}|j|ƒdVq:W|d}qW|r|j|ƒdVndS(sÓReturn an iterator to yield lines from the raw stream. This is achieved by reading chunk of bytes (of size chunk_size) at a time from the raw stream, and then yielding lines from there. tiÿÿÿÿiN(R t splitlinesR(R t chunk_sizetkeependstpendingRtlinestline((s</opt/awscli/lib/python2.7/site-packages/botocore/response.pyt iter_lineshsccs5x.tr0|j|ƒ}|dkr(Pn|VqWdS(s\Return an iterator to yield chunks of chunk_size bytes from the raw stream. R&N(RR(R R(R$((s</opt/awscli/lib/python2.7/site-packages/botocore/response.pyR ws   cCsO|jdk rK|jt|jƒkrKtd|jdt|jƒƒ‚ndS(Nt actual_bytestexpected_bytes(R RR tintR(R ((s</opt/awscli/lib/python2.7/site-packages/botocore/response.pyRs  cCs|jjƒdS(s*Close the underlying http response stream.N(R tclose(R ((s</opt/awscli/lib/python2.7/site-packages/botocore/response.pyR1‹sN(t__name__t __module__t__doc__R!RRRRR"R%tnexttFalseR-R RR1(((s</opt/awscli/lib/python2.7/site-packages/botocore/response.pyRs       cCs«|jd}i|jd6|jd6}|ddkrG|j|ds  s