U eJ%@sddlmZddlZddlZddlZddlmZddlm Z ddl m Z ddl m Z mZddlmZmZdd lmZdd lmZd d lmZejrdd lmZmZeeZe GdddZGdddeZ dS)) annotationsN)contextmanager) dataclass) HTTPException)BytesIOIOBase) InvalidHeader TimeoutError)BaseHTTPResponse)Retry)EmscriptenRequest)BaseHTTPConnectionBaseHTTPSConnectionc@s.eZdZUded<ded<ded<ded<d S) EmscriptenResponseint status_codezdict[str, str]headerszIOBase | bytesbodyrrequestN)__name__ __module__ __qualname____annotations__rrQ/opt/hc_python/lib/python3.8/site-packages/urllib3/contrib/emscripten/response.pyrs rcs4eZdZd5ddddfdd Zeddd d Zejdd d d d ZeddddZeddddZejdd dddZd6ddddddZ dddddZ d7ddd d!d"d#d$Z d8ddddd%d&Z d dd'd(Z d dd)d*Zed!dd+d,Zd-dd.d/Zd dd0d1Zed2dd3d4ZZS)9EmscriptenHttpResponseWrapperNrz str | Nonez/BaseHTTPConnection | BaseHTTPSConnection | None)internal_responseurl connectioncs\d|_d|_||_||_||_d|_tj|j|j |dddd| |jj j |_ d|_dS)NFrT)rstatus request_urlversionreasondecode_content)_pool_body _response_url _connection_closedsuper__init__rr _init_lengthrmethodlength_remaininglength_is_certain)selfrrr  __class__rrr.s z&EmscriptenHttpResponseWrapper.__init__)returncCs|jSNr*r3rrrr6sz!EmscriptenHttpResponseWrapper.urlNone)rr6cCs ||_dSr7r8)r3rrrrr:scCs|jSr7)r+r9rrrr >sz(EmscriptenHttpResponseWrapper.connectionz Retry | NonecCs|jSr7Z_retriesr9rrrretriesBsz%EmscriptenHttpResponseWrapper.retries)r<r6cCs ||_dSr7r;)r3r<rrrr<Fsz int | Nonez bool | Nonez#typing.Generator[bytes, None, None])amtr&r6ccs"|j||d}|r|VqqqdS)a_ A generator wrapper for the read() method. A call will block until ``amt`` bytes have been read from the connection or until the connection is closed. :param amt: How much of the content to read. The generator will return up to much data per iteration, but may return less. This is particularly likely when using compressed data. However, the empty string will never be returned. :param decode_content: If True, will attempt to decode the body based on the 'content-encoding' header. )r>r&Nread)r3r>r&datarrrstreamKsz$EmscriptenHttpResponseWrapper.stream)request_methodr6cCs|jd}|dk rtz8dd|dD}t|dkrBtd||}Wntk rdd}YqxX|dkrxd}nd}|jdksd |jkrd ksn|d krd}|S) Nzcontent-lengthcSsh|] }t|qSr)r).0valrrr psz=EmscriptenHttpResponseWrapper._init_length..,r z8Content-Length contained multiple unmatching values (%s)r)i0dHEAD)rgetsplitlenr pop ValueErrorr")r3rCcontent_lengthlengthslengthrrrr/es6    z*EmscriptenHttpResponseWrapper._init_lengthFboolbytes)r>r& cache_contentr6c Csp|js(|jdks(t|jjtr,|jjjr,dS|0t|jjtsjt|jj|_d|_ t |jj|j_|dk rd}|jj |}|jdk rt |jt|d|_|j r|jdkst||kr|jj tt|W5QRS|jj }|r||_|jdk rt |jt|d|_t|dks>|j rJ|jdkrJ|jj tt|W5QRSW5QRXdS)NTFr)r,r) isinstancerrclosed_error_catcherrNr1r2rr@maxclosetypingcastrUr()r3r>r&rVrArrrr@sL       z"EmscriptenHttpResponseWrapper.readccs|||}|sq|VqdSr7r?)r3r>r&rUrrr read_chunkeds z*EmscriptenHttpResponseWrapper.read_chunkedcCs(|jr |jsdS|j|jd|_dSr7)r'r+ _put_connr9rrr release_conns z*EmscriptenHttpResponseWrapper.release_conncCs |dSr7)r\r9rrr drain_connsz(EmscriptenHttpResponseWrapper.drain_conncCs|jr |jS|jddSdS)NT)rV)r(r@r9rrrrAsz"EmscriptenHttpResponseWrapper.dataz typing.AnycCs|jd}t|S)a Parses the body of the HTTP response as JSON. To use a custom JSON decoder pass the result of :attr:`HTTPResponse.data` to the decoder. This method can raise either `UnicodeDecodeError` or `json.JSONDecodeError`. Read more :ref:`here `. zutf-8)rAdecode_jsonloads)r3rArrrjsons z"EmscriptenHttpResponseWrapper.jsoncCs@|jss"