5,j%ddlmZddlZddlZddlZddlmZddlm Z ddl m Z ddl m Z mZddlmZmZdd lmZdd lmZd d lmZejrdd lmZmZejeZe GddZGddeZ dS)) annotationsN)contextmanager) dataclass) HTTPException)BytesIOIOBase) InvalidHeader TimeoutError)BaseHTTPResponse)Retry)EmscriptenRequest)BaseHTTPConnectionBaseHTTPSConnectionc8eZdZUded<ded<ded<ded<d S) EmscriptenResponseint status_codezdict[str, str]headerszIOBase | bytesbodyrrequestN)__name__ __module__ __qualname____annotations__SC:\PYTHON\GemmaClient\venv\Lib\site-packages\urllib3/contrib/emscripten/response.pyrrsBrrc4eZdZ d)d*fd Zed+d Zejd,d Zed-d Zed.dZejd/dZ d0d1dZ d2dZ d3d4dZ d)d1d Z d5d!Z d5d"Zed6d#Zd7d%Zd5d&Zed8d(ZxZS)9EmscriptenHttpResponseWrapperNinternal_responserurl str | None connection/BaseHTTPConnection | BaseHTTPSConnection | Nonec .d|_d|_d|_||_||_||_d|_t|j |j |dddd| |jj j |_d|_dS)NFrzHTTP/?T)rstatus request_urlversionversion_stringreasondecode_content)_pool_body_uncached_read_occurred _response_url _connection_closedsuper__init__rr _init_lengthrmethodlength_remaininglength_is_certain)selfr"r#r% __class__s rr7z&EmscriptenHttpResponseWrapper.__init__s   ',$* %  %-$0#    !% 1 1$.2H2O P P!&rreturnc|jSNr3r<s rr#z!EmscriptenHttpResponseWrapper.url8s yrNonec||_dSr@rA)r<r#s rr#z!EmscriptenHttpResponseWrapper.url<s  rc|jSr@)r4rBs rr%z(EmscriptenHttpResponseWrapper.connection@s r Retry | Nonec|jSr@_retriesrBs rretriesz%EmscriptenHttpResponseWrapper.retriesDs }rrJc||_dSr@rH)r<rJs rrJz%EmscriptenHttpResponseWrapper.retriesHs  ramt int | Noner. bool | Nonetyping.Generator[bytes]c#JK |||}|r|VndS!)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. T)rMr.Nread)r<rMr.datas rstreamz$EmscriptenHttpResponseWrapper.streamMs=$ 99^9DDD    rrequest_methodct|jd}|t d|dD}t|dkrt d|z|}|dkrd}n#t $rd}YnwxYwd}|jdvsd|jcxkrd ksn|d krd}|S) Nzcontent-lengthc,h|]}t|Sr)r).0vals r z=EmscriptenHttpResponseWrapper._init_length..rsIII3s88IIIr,rz8Content-Length contained multiple unmatching values (%s)r)i0dHEAD)rgetsplitlenr pop ValueErrorr))r<rVcontent_lengthlengthslengths rr8z*EmscriptenHttpResponseWrapper._init_lengthgs %)\%5%56F%G%G  % " JI~/C/CC/H/HIIIw<.77&<@N>GGc#FK |||}|sdS|Vr@rR)r<rMr.rks r read_chunkedz*EmscriptenHttpResponseWrapper.read_chunkeds9  IIc>22E KKK  rcr|jr|jsdS|j|jd|_dSr@)r/r4 _put_connrBs r release_connz*EmscriptenHttpResponseWrapper.release_connsBz !1 4 T-...rc.|dSr@)rqrBs r drain_connz(EmscriptenHttpResponseWrapper.drain_conns rcJ|jr|jS|dS)NT)ri)r0rSrBs rrTz"EmscriptenHttpResponseWrapper.datas( : 1: 994900 0r typing.Anyc^|jd}tj|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)rTdecode_jsonloads)r<rTs rjsonz"EmscriptenHttpResponseWrapper.jsons)$y(({4   rc|jsmt|jjtr|jj|jr |jd|_d|_dSdS)NT)r5rmr2rrrqr4rBs rrqz#EmscriptenHttpResponseWrapper.closesw| $.-v66 ,#))+++ ( &&(((#' DLLL   rtyping.Generator[None]c#Kddlm}m}d} dVd}nM#|$r!}tt |d}~w|$r!}t t |d}~wwxYw |sdt |jjtr/|jjj s|jj | dSt |jjtr'|jjj r| dSdSdS#|sct |jjtr/|jjj s|jj | wt |jjtr&|jjj r| wwwxYw)z Catch Emscripten specific exceptions thrown by fetch.py, instead re-raising urllib3 variants, so that low-level exceptions are not leaked in the high-level api. On exit, release the connection back to the pool. r) _RequestError _TimeoutErrorFNT) fetchrrr strrrmr2rrrnrqrx)r<rr clean_exites rroz,EmscriptenHttpResponseWrapper._error_catchers 87777777  ( EEEJJ ' ' 's1vv&& & ( ( (A'' ' (  (t~2F;;0 N/60N'--///!!##### t~2F;;(+2(%%''''' (((( (t~2F;;0 N/60N'--///!!#### t~2F;;(+2(%%'''' ((s/DA6AAADB-G)NN)r"rr#r$r%r&)r>r$)r#r$r>rC)r>r&)r>rF)rJrFr>rC)rLN)rMrNr.rOr>rP)rVr$r>rN)NNF)rMrNr.rOrirjr>rk)r>rC)r>rk)r>r|)r>r)rrrr7propertyr#setterr%rJrUr8rSrurxrzrTrrqrro __classcell__)r=s@rr!r!sFJ '''''''2X ZZ   X X ^   ^ FJ4####N&*# &,&,&,&,&,T&*         111X1 !!!!*    )()()(^)()()()()(rr!)! __future__rrrloggingrr contextlibr dataclassesr http.clientriorr exceptionsr r responser util.retryr rr TYPE_CHECKING_base_connectionrr getLoggerrlogrr!rrrrsz"""""" %%%%%%!!!!!!66666655555555((((((&&&&&& LKKKKKKKKg!!  {({({({({($4{({({({({(r