\hwddlmZddlZddlZddlZddlZddlZddlmZddl m Z ddl m Z dZddlmZddlmZdd lmZmZdd lmZmZmZmZmZmZmZmZmZm Z dd l!m"Z"dd l#m$Z$m%Z%ejLe'Z(Gd de)Z*Gdde)Z+Gdde)Z,e Gdde)Z-Gdde)Z.dZ/Gddej`Z1y))absolute_importN)contextmanager)error)timeout)util)HTTPHeaderDict) BaseSSLError HTTPException) BodyNotHttplibCompatible DecodeError HTTPErrorIncompleteReadInvalidChunkLength InvalidHeader ProtocolErrorReadTimeoutErrorResponseNotChunkedSSLError)six) is_fp_closedis_response_to_headceZdZdZdZdZy)DeflateDecodercRd|_d|_tj|_y)NT) _first_try_datazlib decompressobj_objselfs _/root/niggaflix-v3/playground/venv/lib/python3.12/site-packages/pip/_vendor/urllib3/response.py__init__zDeflateDecoder.__init__$s  &&( rc.t|j|SNgetattrr!r#names r$ __getattr__zDeflateDecoder.__getattr__)tyy$''rc|s|S|js|jj|S|xj|z c_ |jj|}|rd|_d|_|S#tj $rbd|_t j tj |_ |j|jd|_cYS#d|_wxYwwxYw)NF)rr! decompressrrrr MAX_WBITS)r#data decompresseds r$r/zDeflateDecoder.decompress,sK99''- - d  "99//5L"'!  zz "#DO**DNN?;DI "tzz2! T  "s%,A//AC$3C C$ C  C$N__name__ __module__ __qualname__r%r,r/rr$rr#s) ("rrceZdZdZdZdZy)GzipDecoderStaterrN)r4r5r6 FIRST_MEMBER OTHER_MEMBERS SWALLOW_DATAr7rr$r9r9CsLMLrr9ceZdZdZdZdZy) GzipDecoderctjdtjz|_tj |_yN)rr r0r!r9r;_stater"s r$r%zGzipDecoder.__init__Ks*&&rDNN':; &33 rc.t|j|Sr'r(r*s r$r,zGzipDecoder.__getattr__Or-rc$t}|jtjk(s|s t |S ||j j |z }|j j}|s t |Stj|_tjdtjz|_#tj$rC|j}tj|_|tjk(r t |cYSwxYwrA) bytearrayrCr9r=bytesr!r/rrr< unused_datar r0)r#r1retprevious_states r$r/zGzipDecoder.decompressRsk ;;*77 7t:  tyy++D1199((DSz!*88DK**2+>?DI:: !%.;; !%5%C%CC :% sB99AD DNr3r7rr$r?r?Js4(@rr?ceZdZdZdZy) BrotliDecoderctj|_t|jdr|jj|_y|jj |_y)Nr/)brotli Decompressorr!hasattrr/processr"s r$r%zBrotliDecoder.__init__nsB++-DItyy,/"&))"6"6"&))"3"3rcdt|jdr|jjSy)Nflushr)rPr!rSr"s r$rSzBrotliDecoder.flushus$tyy'*yy((rN)r4r5r6r%rSr7rr$rLrLjs  4 rrLc"eZdZdZdZdZdZy) MultiDecodera From RFC7231: If one or more encodings have been applied to a representation, the sender that applied the encodings MUST generate a Content-Encoding header field that lists the content codings in the order in which they were applied. c|jdDcgc]}t|jc}|_ycc}w)N,)split _get_decoderstrip _decoders)r#modesms r$r%zMultiDecoder.__init__s+;@;;s;KLa,qwwy1LLs =c<|jdjSNr)r[rSr"s r$rSzMultiDecoder.flushs~~a &&((rc\t|jD]}|j|}|Sr')reversedr[r/)r#r1ds r$r/zMultiDecoder.decompresss-$..) &A<<%D & rN)r4r5r6__doc__r%rSr/r7rr$rUrU{sM)rrUc|d|vr t|S|dk(r tSt|dk(r tSt S)NrWgzipbr)rUr?rNrLr)modes r$rYrYs@ d{D!! v~} ddl  rceZdZdZddgZeedgz ZgdZ d'dZdZd Z d Z e d Z e d Z d ZdZdZdZeej(fZeeej(fz ZdZdZedZdZd(dZd)dZedZdZd*dZ dZ!dZ"e dZ#dZ$dZ%dZ&d Z'd!Z(d"Z)d#Z*d+d$Z+d%Z,d&Z-y), HTTPResponsea HTTP Response container. Backwards-compatible with :class:`http.client.HTTPResponse` but the response ``body`` is loaded and decoded on-demand when the ``data`` property is accessed. This class is also compatible with the Python standard library's :mod:`io` module, and can hence be treated as a readable object in the context of that framework. Extra parameters for behaviour not present in :class:`http.client.HTTPResponse`: :param preload_content: If True, the response's body will be preloaded during construction. :param decode_content: If True, will attempt to decode the body based on the 'content-encoding' header. :param original_response: When this HTTPResponse wrapper is generated from an :class:`http.client.HTTPResponse` object, it's convenient to include the original for debug purposes. It's otherwise unused. :param retries: The retries contains the last :class:`~urllib3.util.retry.Retry` that was used during the request. :param enforce_content_length: Enforce content length checking. Body returned by server must match value of Content-Length header, if present. Otherwise, raise error. redeflateNrf)i-i.i/i3i4ct|tr||_nt||_||_||_||_||_||_| |_||_ ||_ d|_ d|_ d|_ | |_d|_| |_||_|r't|t$j&t(fr||_ | |_| |_t/|dr||_ d|_d|_|jj5ddj7}d|j9dD}d|vrd |_|j;||_|r%|js|j?| |_ yyy) NrreadFztransfer-encodingc3<K|]}|jywr')rZ).0encs r$ z(HTTPResponse.__init__..s>SSYY[>srWchunkedTdecode_content) isinstancer headersstatusversionreasonstrictrtretriesenforce_content_length auto_close_decoder_body_fp_original_response_fp_bytes_readmsg _request_urlr string_typesrG_pool _connectionrPrr chunk_leftgetlowerrX _init_lengthlength_remainingrl)r#bodyrvrwrxryrzpreload_contentrtoriginal_responsepool connectionrr{r|request_method request_urlr}tr_enc encodingss r$r%zHTTPResponse.__init__sX* g~ ."DL)'2DL    , &<#$  "3' Jtc&6&6%>?DJ % 4 DH !!"5r:@@B>FLL,=>  !DL!% 1 1. A 4::.ADJ$.?rcj|j|jvr|jjdSy)a Should we redirect and where to? :returns: Truthy redirect location string if we got a redirect status code and valid location. ``None`` if redirect status and no location. ``False`` if not a redirect status code. locationF)rwREDIRECT_STATUSESrvrr"s r$get_redirect_locationz"HTTPResponse.get_redirect_locations. ;;$00 0<<##J/ /rc|jr |jsy|jj|jd|_yr')rr _put_connr"s r$ release_connzHTTPResponse.release_conns4zz!1!1  T--.rcd |jy#ttttf$rYywxYw)z Read and discard any remaining HTTP response data in the response connection. Unread data in the HTTPResponse connection blocks the connection from being released back to the pool. N)rlr SocketErrorr r r"s r$ drain_connzHTTPResponse.drain_conns+   IIK; mD   s //cp|jr |jS|jr|jdSy)NT) cache_content)rrrlr"s r$r1zHTTPResponse.data%s2 ::::  8899490 0 rc|jSr')rr"s r$rzHTTPResponse.connection.src,t|jSr')rrr"s r$isclosedzHTTPResponse.isclosed2sDHH%%rc|jS)z Obtain the number of bytes pulled over the wire so far. May differ from the amount of content returned by :meth:``urllib3.response.HTTPResponse.read`` if bytes are encoded on the wire (e.g, compressed). )rr"s r$tellzHTTPResponse.tell5s """rc|jjd}||jrtj dy t |j dDcgc] }t|c}}t|dkDrtd|z|j}|dkrd} t|j}|dvsd |cxkrd ksn|d k(rd}|Scc}w#t$rd}YBwxYw#t$rd}Y=wxYw) zM Set initial length value for Response content if available. zcontent-lengthNzReceived response with both Content-Length and Transfer-Encoding set. This is expressly forbidden by RFC 7230 sec 3.3.2. Ignoring Content-Length and attempting to process response as Transfer-Encoding: chunked.rWrz8Content-Length contained multiple unmatching values (%s)r)i0dHEAD) rvrrrlogwarningsetrXintlenrpop ValueErrorrw)r#rlengthvallengthsrws r$rzHTTPResponse._init_length=s!!"23  ||  " 6<<3DECs3xEFwCIIK == 4#8#88 ,-= > ((.33C8wwyD$9$99GGI  y>$01A$BDM" ) !s-3Cc(|s|S |jr|jj|}|r||jz }|S#|j$r>}|jj ddj }t d|z|d}~wwxYw)zN Decode the data passed in and potentially flush the decoder. rrmzEReceived response with content-encoding: %s, but failed to decode it.N)r~r/DECODER_ERROR_CLASSESrvrrr _flush_decoder)r#r1rt flush_decoderrrs r$_decodezHTTPResponse._decodesK }}}}//5  D'') )D )) #||//0BBGMMO ')9:  s'AB9B  Bc|jr8|jjd}||jjzSy)zk Flushes the decoder. Should only be called if the decoder is actually being used. r)r~r/rS)r#bufs r$rzHTTPResponse._flush_decoders: ==--**3/C,,.. .rc#BKd} dd}|sL|jr|jj|jr|jj|jr,|jjr|jyyy#t$rt|jddt$r4}dt |vr t |t|jddd}~wt tf$r}td|z|d}~wwxYw#|sL|jr|jj|jr|jj|jr,|jjr|jwwwxYww)z Catch low-level python exceptions, 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. FNzRead timed out.zread operation timed outzConnection broken: %rT) SocketTimeoutrrr strrr rrrcloserrr)r# clean_exitrs r$_error_catcherzHTTPResponse._error_catchers + $ D*J**++113 ##$$**,&&4+B+B+K+K+M!!#,N&M! L'tzz49JKK L-SV;"1+%&tzz49JKK!;/ D#$;a$?CC D**++113 ##$$**,&&4+B+B+K+K+M!!#,N&sFFBDBF(D2ww(55g>(9Ha(  88II88     rcRtjdtd|jS)Nz|HTTPResponse.getheaders() is deprecated and will be removed in urllib3 v2.1.0. Instead access HTTPResponse.headers directly.r:category stacklevel)warningswarnDeprecationWarningrvr"s r$ getheaderszHTTPResponse.getheaderss&  O'  ||rcrtjdtd|jj ||S)NzHTTPResponse.getheader() is deprecated and will be removed in urllib3 v2.1.0. Instead use HTTPResponse.headers.get(name, default).r:r)rrrrvr)r#r+defaults r$ getheaderzHTTPResponse.getheaders3  V'  ||g..rc|jSr')rvr"s r$infozHTTPResponse.infos ||rc|js|jj|jr|jj|js t j j|yyr')rrrrr}rIOBaser"s r$rzHTTPResponse.closesN{{ HHNN        " " $ IIOOD !rc@|js)tjjj |S|j yt |j dr|j jSt |j dr|j jSy)NTrr)r}rrr__get__rrPrr"s r$rzHTTPResponse.closedsq99##++D1 1 XX  TXXz *88$$& & TXXx (88?? "rc|j tdt|jdr|jjStd)Nz-HTTPResponse has no file to get a fileno fromfilenozOThe file-like object this HTTPResponse is wrapped around has no file descriptor)rIOErrorrPrr"s r$rzHTTPResponse.filenosI 88 IJ J TXXx (88??$ $0 rc|jIt|jdr2t|jdds|jjSyyy)NrSrF)rrPr)rSr"s r$rSzHTTPResponse.flushsJ HH '*DHHh688>># #7+ !rcy)NTr7r"s r$readablezHTTPResponse.readablesrc|jt|}t|dk(ry||dt|t|Sr_)rlr)r#btemps r$readintozHTTPResponse.readintos;yyQ  t9>!AkD Nt9 rc.t|jdS)a Checks if the underlying file-like object looks like a :class:`http.client.HTTPResponse` object. We do this by testing for the fp attribute. If it is present we assume it returns raw chunks as processed by read_chunked(). fp)rPrr"s r$rz#HTTPResponse.supports_chunked_readsstxx&&rc|jy|jjj}|j ddd} t |d|_y#t $r|jt||wxYw)N;rrrB) rrrreadlinerXrrrr)r#rs r$_update_chunk_lengthz!HTTPResponse._update_chunk_lengthss ?? & xx{{##%zz$"1% 1!$mDO 1 JJL$T40 0 1s A&BcVd}|K|jj|j}|}|jjdd|_|S||jkr3|jj|}|j|z |_|}|S||jk(rA|jj|}|jjdd|_|}|S|jj|j}|jjdd|_|S)Nr:)r _safe_readr)r#rreturned_chunkchunkvalues r$ _handle_chunkzHTTPResponse._handle_chunks  ;HH''8E"N HH   ""DO4?? "HH'',E"oo3DO"NDOO #HH'',E HH   ""DO"N "XX00AN HH   ""DOrc#K|j|js td|js t d|j 5|j r9t|j r$|j j dddy|jj dddy |j|jdk(rn,|j|}|j||d}|r|L|r|j}|r| |jjj!}|sn|dk(rn.|j r|j jdddy#1swYyxYww)a Similar to :meth:`HTTPResponse.read`, but with an additional parameter: ``decode_content``. :param amt: How much of the content to read. If specified, caching is skipped because it doesn't make sense to cache partial content as the full response. :param decode_content: If True, will attempt to decode the body based on the 'content-encoding' header. zHResponse is not chunked. Header 'transfer-encoding: chunked' is missing.zkBody should be http.client.HTTPResponse like. It should have have an fp attribute which returns raw chunks.NrF)rtrs )rrrrrr rrrrrrr rrrrr )r#rrtrdecodedrs r$rzHTTPResponse.read_chunkeds ||$B **,*P   ") 0&&+>t?V?V+W''--/ ) 0) 0xx{{") 0) 0))+??a'**3/,,.'!M--/!Mxx{{++-7? &&''--/S) 0) 0) 0s7AF =E> F E>2 F ;B:E>5 F >FF c|jBt|jjr#|jjdjS|jS)z Returns the URL that was the source of this response. If the request that generated this response redirected, this method will return the final redirect location. )r{rhistoryredirect_locationrr"s r$geturlzHTTPResponse.geturlUsF << #DLL,@,@(A<<''+== =$$ $rc#.Kg}|jdD]d}d|vrM|jd}dj||dzdz|ddD] }|dz |dr|dg}Qg}T|j|f|rdj|yyw)NTrs rrrr)rrXjoinappend)r#rrxs r$__iter__zHTTPResponse.__iter__`s[[[5 %E~ E*hhv&q1E99q$Ae)O$9#Bi[FF e$ % ((6" " sBB)rmNrrNrTTNNNNNFNNT)NNF)iNr')NN).r4r5r6rcrrNrr%rrrpropertyr1rrrrrrrrrrrrrrrlr classmethodrrrrrrrrSrrrr rrrrr7rr$riris@ * TF"1  $%ABF   11  &#2hC&%djj1 &,,0, 5$5$n.N`FP4@/"   $' 1,D0L %#rri)2 __future__rrloggingrrr contextlibrsocketrrrrrNrmr _collectionsr rr r exceptionsr r rrrrrrrrpackagesr util.responserr getLoggerr4robjectrr9r?rLrUrYrrir7rr$r+s&   %'+ (3   <g!"V"@v@&@< "6* R #299R #r