U f!'@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__rrT/opt/alt/python38/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 connectionc s^d|_d|_||_||_||_d|_tj|j|j |ddddd| |jj j |_ d|_dS)NFrzHTTP/?T)rstatus request_urlversionversion_stringreasondecode_content)_pool_body _response_url _connection_closedsuper__init__rr _init_lengthrmethodlength_remaininglength_is_certain)selfrrr  __class__rrr/s" z&EmscriptenHttpResponseWrapper.__init__)returncCs|jSNr+r4rrrr7sz!EmscriptenHttpResponseWrapper.urlNone)rr7cCs ||_dSr8r9)r4rrrrr;scCs|jSr8)r,r:rrrr ?sz(EmscriptenHttpResponseWrapper.connectionz Retry | NonecCs|jSr8Z_retriesr:rrrretriesCsz%EmscriptenHttpResponseWrapper.retries)r=r7cCs ||_dSr8r<)r4r=rrrr=Gsz int | Nonez bool | Nonez#typing.Generator[bytes, None, None])amtr'r7ccs"|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)r4r?r'datarrrstreamLsz$EmscriptenHttpResponseWrapper.stream)request_methodr7cCs|jd}|dk rtz8dd|dD}t|dkrBtd||}Wntk rdd}YqxX|dkrxd}nd}|jdksd |jkrd ksn|d krd}|S) Nzcontent-lengthcSsh|] }t|qSr)r).0valrrr qsz=EmscriptenHttpResponseWrapper._init_length..,r z8Content-Length contained multiple unmatching values (%s)r)i0dHEAD)rgetsplitlenr pop ValueErrorr")r4rDcontent_lengthlengthslengthrrrr0fs6    z*EmscriptenHttpResponseWrapper._init_lengthFboolbytes)r?r' cache_contentr7c Csz|js(|jdks(t|jjtr,|jjjr,dS|:t|jjtsjt|jj|_d|_ t |jj|j_|dk r|dkrd}|jj |}|jdk rt |jt|d|_|j r|jdkst||kr|jj tt|W5QRS|jj }|r||_|jdk r&t |jt|d|_t|dksH|j rT|jdkrT|jj tt|W5QRSW5QRXdS)NTrF)r-r* isinstancerrclosed_error_catcherrOr2r3rrAmaxclosetypingcastrVr))r4r?r'rWrBrrrrAsL       z"EmscriptenHttpResponseWrapper.readccs|||}|sq|VqdSr8r@)r4r?r'rVrrr read_chunkeds z*EmscriptenHttpResponseWrapper.read_chunkedcCs(|jr |jsdS|j|jd|_dSr8)r(r, _put_connr:rrr release_conns z*EmscriptenHttpResponseWrapper.release_conncCs |dSr8)r]r:rrr drain_connsz(EmscriptenHttpResponseWrapper.drain_conncCs|jr |jS|jddSdS)NT)rW)r)rAr:rrrrBsz"EmscriptenHttpResponseWrapper.dataz typing.AnycCs|jd}t|S)a Deserializes the body of the HTTP response as a Python object. The body of the HTTP response must be encoded using UTF-8, as per `RFC 8529 Section 8.1 `_. To use a custom JSON decoder pass the result of :attr:`HTTPResponse.data` to your custom decoder instead. If the body of the HTTP response is not decodable to UTF-8, a `UnicodeDecodeError` will be raised. If the body of the HTTP response is not a valid JSON document, a `json.JSONDecodeError` will be raised. Read more :ref:`here `. :returns: The body of the HTTP response as a Python object. zutf-8)rBdecode_jsonloads)r4rBrrrjsons z"EmscriptenHttpResponseWrapper.jsoncCs@|jsN)NNF)NN)rrrr/propertyrsetterr r=rCr0rAr`rbrcrBrgr]rr[ __classcell__rrr5rrs@'/  r)! __future__rrgreloggingr^ contextlibr dataclassesr http.clientriorr exceptionsr r responser Z util.retryr rr TYPE_CHECKINGZ_base_connectionrr getLoggerrlogrrrrrrs"