ó –ee[c@s²ddlZddlZddlZddlmZddlmZddlm Z m Z m Z ddl m Z ddlmZejeƒZdefd„ƒYZd „ZdS( iÿÿÿÿN(t ScalarTypes(tfirst_non_none_response(tjsontset_socket_timeoutt XMLParseError(tIncompleteReadError(tparserst StreamingBodycBseeZdZdZd„Zd„Zd d„Zd„Zdd„Z ed„Z d„Z d „Z RS( 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((s5/tmp/pip-install-xdEqop/botocore/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(RRtAttributeErrortloggerterrortTrue(R ttimeout((s5/tmp/pip-install-xdEqop/botocore/botocore/response.pyR0s   cCsW|jj|ƒ}|jt|ƒ7_|dksF| rS|dkrS|jƒn|S(shRead at most amt bytes from the stream. If the amt argument is omitted, read all data. iN(RtreadR tlentNonet_verify_content_length(R tamttchunk((s5/tmp/pip-install-xdEqop/botocore/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 ((s5/tmp/pip-install-xdEqop/botocore/botocore/response.pyt__iter__Usccs¶d}x•|j|ƒD]„}|dk r5||}n|jƒ}|r~|dr~|r~|dd|dkr~|jƒ}nd}x|D] }|Vq‹WqW|dk r²|VndS(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. iÿÿÿÿN(RRt splitlinestpop(R t chunk_sizetpendingRtlinestline((s5/tmp/pip-install-xdEqop/botocore/botocore/response.pyt iter_linesZs   .   ccs5x.tr0|j|ƒ}|dkr(Pn|VqWdS(s\Return an iterator to yield chunks of chunk_size bytes from the raw stream. tN(RR(R R t current_chunk((s5/tmp/pip-install-xdEqop/botocore/botocore/response.pyRts   cCsO|jdk rK|jt|jƒkrKtd|jdt|jƒƒ‚ndS(Nt actual_bytestexpected_bytes(R RR tintR(R ((s5/tmp/pip-install-xdEqop/botocore/botocore/response.pyR~s  cCs|jjƒdS(s*Close the underlying http response stream.N(Rtclose(R ((s5/tmp/pip-install-xdEqop/botocore/botocore/response.pyR*ˆsN( t__name__t __module__t__doc__RRRRRRR$RRR*(((s5/tmp/pip-install-xdEqop/botocore/botocore/response.pyRs       cCs«|jd}i|jd6|jd6}|ddkrG|j|d(((s5/tmp/pip-install-xdEqop/botocore/botocore/response.pyts   p