K i#%ddlmZddlZddlZddlZddlmZddlm Z ddl m Z ddl m Z mZddlmZmZdd lmZdd lmZd d lmZej0rdd lmZmZej8eZe GddZGddeZ y)) annotationsN)contextmanager) dataclass) HTTPException)BytesIOIOBase) InvalidHeader TimeoutError)BaseHTTPResponse)Retry)EmscriptenRequest)BaseHTTPConnectionBaseHTTPSConnectionc6eZdZUded<ded<ded<ded<y ) EmscriptenResponseint status_codezdict[str, str]headerszIOBase | bytesbodyrrequestN)__name__ __module__ __qualname____annotations__i/mnt/ssd/data/python-lab/Trading/venv/lib/python3.12/site-packages/urllib3/contrib/emscripten/response.pyrrs   rrcJeZdZ d dfd ZeddZej ddZeddZeddZej ddZ d ddZ ddZ d dd Z d dd Z dd Z dd Zedd ZddZddZed dZxZS)!EmscriptenHttpResponseWrapperc $d|_d|_||_||_||_d|_t ||j|j|dddd|j|jjj|_ d|_y)NFrzHTTP/?T)rstatus request_urlversionversion_stringreasondecode_content)_pool_body _response_url _connection_closedsuper__init__rr _init_lengthrmethodlength_remaininglength_is_certain)selfinternal_responseurl connection __class__s rr1z&EmscriptenHttpResponseWrapper.__init__s   * %  %--$00#  !% 1 1$..2H2H2O2O P!&rc|jSNr-r6s rr8z!EmscriptenHttpResponseWrapper.url7s yyrc||_yr<r=)r6r8s rr8z!EmscriptenHttpResponseWrapper.url;s  rc|jSr<)r.r>s rr9z(EmscriptenHttpResponseWrapper.connection?src|jSr<_retriesr>s rretriesz%EmscriptenHttpResponseWrapper.retriesCs }}rc||_yr<rB)r6rDs rrDz%EmscriptenHttpResponseWrapper.retriesGs   rc#DK |j||}|r|nyw)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. )amtr)Nread)r6rGr)datas rstreamz$EmscriptenHttpResponseWrapper.streamLs-$99^9DD  s c|jjd}|\ |jdDchc] }t|}}t |dkDrt d|z|j }|dkrd}nd}|jdvsd|jcxkrdksn|d k(rd}|Scc}w#t$rd}Y@wxYw) Nzcontent-length,rz8Content-Length contained multiple unmatching values (%s)r)i0dHEAD) rgetsplitrlenr pop ValueErrorr$)r6request_methodcontent_lengthvallengthslengths rr2z*EmscriptenHttpResponseWrapper._init_lengthfs%)\\%5%56F%G  % " 0>/C/CC/HI3s8IIw>..7DNN2EK sc|jr |jsy|jj|jd|_yr<)r*r. _put_connr>s r release_connz*EmscriptenHttpResponseWrapper.release_conns4zz!1!1 T--.rc$|jyr<)rar>s r drain_connz(EmscriptenHttpResponseWrapper.drain_conns  rcV|jr |jS|jdS)NT)re)r+rIr>s rrJz"EmscriptenHttpResponseWrapper.datas$ :::: 99490 0rcb|jjd}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)rJdecode_jsonloads)r6rJs rjsonz"EmscriptenHttpResponseWrapper.jsons'$yy({{4  rc|js}t|jjtr$|jjj |j r!|j j d|_d|_yy)NT)r/r]r,rrrar.r>s rraz#EmscriptenHttpResponseWrapper.closesb||$..--v6##))+  &&(#' DL rc#Kddlm}m}d} dd} |syt |jjtrD|jjjs$|jjj|jyt |jjtr2|jjjr|jyyy#|$r}tt |d}~w|$r}t t |d}~wwxYw#|syt |jjtrD|jjjs$|jjj|jwt |jjtr2|jjjr|jwwwxYww)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) fetchrurvr strrr]r,rrr^rarj)r6rurv clean_exites rr_z,EmscriptenHttpResponseWrapper._error_catchersv 8  ( Jt~~22F; NN//66NN''--/!!# t~~22F;++22%%'3<+ 's1v& & (A' ' ( t~~22F; NN//66NN''--/!!# t~~22F;++22%%'3rso" %!65(& Kg!  w($4w(r