ó U!¶\c@sÈddlZddlZddlZddlmZddlmZddlm Z m Z m Z ddl m Z mZddlmZddlmZejeƒZdefd „ƒYZd „ZdS( iÿÿÿÿN(t ScalarTypes(tfirst_non_none_response(tjsontset_socket_timeoutt XMLParseError(tIncompleteReadErrortReadTimeoutError(R(tparserst StreamingBodycBsteZdZdZd„Zd„Zd d„Zd„Zd„Z e Z dd„Z ed„Z d „Z d „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((s5/tmp/pip-install-usGedi/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(RR tAttributeErrortloggerterrortTrue(R ttimeout((s5/tmp/pip-install-usGedi/botocore/botocore/response.pyR1s   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((s5/tmp/pip-install-usGedi/botocore/botocore/response.pyRHs 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-usGedi/botocore/botocore/response.pyt__iter__ZscCs)|j|jƒ}|r|Stƒ‚dS(s6Return the next 1k chunk from the raw stream. N(RR!t StopIteration(R t current_chunk((s5/tmp/pip-install-usGedi/botocore/botocore/response.pyt__next___sccs}d}xX|j|ƒD]G}||jtƒ}x!|d D]}|jƒdVq:W|d}qW|ry|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_sizetpendingRtlinestline((s5/tmp/pip-install-usGedi/botocore/botocore/response.pyt iter_linesisccs5x.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$((s5/tmp/pip-install-usGedi/botocore/botocore/response.pyR xs   cCsO|jdk rK|jt|jƒkrKtd|jdt|jƒƒ‚ndS(Nt actual_bytestexpected_bytes(R RR tintR(R ((s5/tmp/pip-install-usGedi/botocore/botocore/response.pyR‚s  cCs|jjƒdS(s*Close the underlying http response stream.N(R tclose(R ((s5/tmp/pip-install-usGedi/botocore/botocore/response.pyR0ŒsN(t__name__t __module__t__doc__R!RRRRR"R%tnextR,R RR0(((s5/tmp/pip-install-usGedi/botocore/botocore/response.pyRs        cCs«|jd}i|jd6|jd6}|ddkrG|j|ds   s