Viewing File: /opt/imunify360/venv/lib/python3.11/site-packages/urllib3/__pycache__/response.cpython-311.pyc



]j+nddlmZddlZddlZddlZddlmZddlmZ	ddlm
Z	ddlZn
#e
$rdZYnwxYwddlmZddlmZmZdd	lmZmZmZmZmZmZmZmZmZmZdd
lmZddl m!Z!m"Z"ej#e$Z%Gdd
e&Z'Gdde&Z(Gdde&Z)eGdde&Z*Gdde&Z+dZ,Gddej-Z.dS))absolute_importN)contextmanager)error)timeout)HTTPHeaderDict)BaseSSLError
HTTPException)
BodyNotHttplibCompatibleDecodeError	HTTPErrorIncompleteReadInvalidChunkLength
InvalidHeader
ProtocolErrorReadTimeoutErrorResponseNotChunkedSSLError)six)is_fp_closedis_response_to_headc eZdZdZdZdZdS)DeflateDecodercRd|_d|_tj|_dS)NT)
_first_try_datazlib
decompressobj_objselfs G/opt/imunify360/venv/lib64/python3.11/site-packages/urllib3/response.py__init__zDeflateDecoder.__init__$s$
&((			rc,t|j|SNgetattrr r"names  r#__getattr__zDeflateDecoder.__getattr__)ty$'''rc|s|S|js|j|S|xj|z
c_	|j|}|rd|_d|_|S#tj$r\d|_t	jtj|_	||jd|_cYS#d|_wxYwwxYw)NF)rr 
decompressrrrr	MAX_WBITS)r"datadecompresseds   r#r.zDeflateDecoder.decompress,s	K	.9''---

d

	"9//55L
""'!
z	"	"	"#DO*DN?;;DI
"tz22!



T
!!!!
	"s#+A##:CC7C	C

CN__name__
__module____qualname__r$r+r.rr#rr#sA)))
((("""""rrceZdZdZdZdZdS)GzipDecoderStaterrN)r3r4r5FIRST_MEMBER
OTHER_MEMBERSSWALLOW_DATAr6rr#r8r8CsLMLLLrr8c eZdZdZdZdZdS)GzipDecodercttjdtjz|_tj|_dS)N)rrr/r r8r:_stater!s r#r$zGzipDecoder.__init__Ks)&rDN':;;	&3rc,t|j|Sr&r'r)s  r#r+zGzipDecoder.__getattr__Or,rct}|jtjks|st	|S		||j|z
}nM#tj$r;|j}tj|_|tj	krt	|cYSwxYw|jj
}|st	|Stj	|_tjdtjz|_)NTr@)
	bytearrayrAr8r<bytesr r.rrr;unused_datarr/)r"r0retprevious_states    r#r.zGzipDecoder.decompressRskk;*777t7::	@	
ty++D111:


!%.;!%5%CCC ::%%%
9(D
"Szz!*8DK*2+>??DI	@sAABBNr2r6rr#r>r>JsF444(((@@@@@rr>ceZdZdZdZdS)
BrotliDecoderctj|_t|jdr|jj|_dS|jj|_dS)Nr.)brotliDecompressorr hasattrr.processr!s r#r$zBrotliDecoder.__init__nsF+--DIty,//
4"&)"6"&)"3rcbt|jdr|jSdS)Nflushr)rNr rQr!s r#rQzBrotliDecoder.flushus-ty'**
)y(((3rN)r3r4r5r$rQr6rr#rJrJjs2	4	4	4					rrJc$eZdZdZdZdZdZdS)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.
    cNd|dD|_dS)NcPg|]#}t|$Sr6)_get_decoderstrip).0ms  r#
<listcomp>z)MultiDecoder.__init__.<locals>.<listcomp>s(LLLa,qwwyy11LLLr,)split	_decoders)r"modess  r#r$zMultiDecoder.__init__s'LL5;;s;K;KLLLrc@|jdSNr)r]rQr!s r#rQzMultiDecoder.flushs~a &&(((rc^t|jD]}||}|Sr&)reversedr]r.)r"r0ds   r#r.zMultiDecoder.decompresss3$.))	&	&A<<%%DDrN)r3r4r5__doc__r$rQr.r6rr#rSrS{sNMMM)))rrScd|vrt|S|dkrtSt|dkrtSt	S)Nr[gzipbr)rSr>rLrJr)modes r#rVrVsP
d{{D!!!v~~}}
ddllrceZdZdZddgZeedgz
ZgdZ																	d+dZdZd
Z	dZ
edZedZ
dZdZdZdZeejfZeeejfz
ZdZdZedZd,dZd-dZedZdZd.dZdZ dZ!ed Z"d!Z#d"Z$d#Z%d$Z&d%Z'd&Z(d'Z)d/d(Z*d)Z+d*Z,dS)0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.
    rfdeflateNrg)i-i.i/i3i4rTFc&t|tr||_nt||_||_||_||_||_||_|
|_||_	||_
d|_d|_d|_
|	|_d|_||_||_|r(t|t$jt(fr||_|
|_||_t/|dr||_
d|_d|_|jdd}d|dD}d|vrd	|_|||_|r$|js||
|_dSdSdS)NrreadFztransfer-encodingrlc3>K|]}|VdSr&)rW)rXencs  r#	<genexpr>z(HTTPResponse.__init__.<locals>.<genexpr>s*>>SSYY[[>>>>>>rr[chunkedTdecode_content) 
isinstancerheadersstatusversionreasonstrictrtretriesenforce_content_length
auto_close_decoder_body_fp_original_response_fp_bytes_readmsg_request_urlrstring_typesrE_pool_connectionrNrr
chunk_leftgetlowerr\_init_lengthlength_remainingrn)r"bodyrvrwrxryrzpreload_contentrtoriginal_responsepool
connectionrr{r|request_methodrequest_urlr}tr_enc	encodingss                    r#r$zHTTPResponse.__init__s*g~..	3"DLL)'22DL,&<#$

"3'	Jtc&6%>??	DJ
%4  	DH!!"5r::@@BB>>FLL,=,=>>>		!!DL!% 1 1. A A	B4:	B.AADJJJ	B	B	B	BrcV|j|jvr|jdSdS)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/;$000<##J///urcr|jr|jsdS|j|jd|_dSr&)rr	_put_connr!s r#release_connzHTTPResponse.release_connsBz	!1	F
T-...rcx	|dS#ttttf$rYdSwxYw)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)rnr
SocketErrorr	r
r!s r#
drain_connzHTTPResponse.drain_connsC	IIKKKKK;mD			DD	s99c\|jr|jS|jr|dSdS)NT)
cache_content)rrrnr!s r#r0zHTTPResponse.data%s>:	:8	19949000	1	1rc|jSr&)rr!s r#rzHTTPResponse.connection.src*t|jSr&)rrr!s r#isclosedzHTTPResponse.isclosed2sDH%%%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|jd}||jrtddS	td|dD}t|dkrtd|z|	}|dkrd}n#t$rd}YnwxYw	t|j}n#t$rd}YnwxYw|d	vsd
|cxkrdksn|dkrd}|S)
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.c,g|]}t|Sr6)int)rXvals  r#rZz-HTTPResponse._init_length.<locals>.<listcomp>WsEEECs3xxEEErr[rz8Content-Length contained multiple unmatching values (%s)r)i0dHEAD)
rvrrrlogwarningsetr\lenrpop
ValueErrorrrw)r"rlengthlengthsrws     r#rzHTTPResponse._init_length=sl!!"233|
t
"EE6<<3D3DEEEFFw<<!##'139:!A::!F	



	%%FF			FFF	Z3&#6#6#6#63#6#6#6#6.F:R:RF
s%A%B//B>=B>CC&%C&cJjdd}ji|jvrt|_dSd|vrHfd|dD}t|rt|_dSdSdSdS)z=
        Set-up the _decoder attribute if necessary.
        content-encodingrlNr[cng|]1}|jv|2Sr6)rWCONTENT_DECODERS)rXer"s  r#rZz.HTTPResponse._init_decoder.<locals>.<listcomp>|sAwwyyD$999GGII999r)rvrrr~rrVr\r)r"content_encodingrs`  r#
_init_decoderzHTTPResponse._init_decoderqs <++,>CCIIKK= 4#888 ,-= > >


(((-33C88	
y>>C$01A$B$BDMMM! )(CCrc*|s|S	|jr|j|}nR#|j$rE}|jdd}t
d|z|d}~wwxYw|r||z
}|S)zN
        Decode the data passed in and potentially flush the decoder.
        rrlzEReceived response with content-encoding: %s, but failed to decode it.N)r~r.DECODER_ERROR_CLASSESrvrrr_flush_decoder)r"r0rt
flush_decoderrrs      r#_decodezHTTPResponse._decodes	K		}
6}//55)			#|//0BBGGMMOO')9:
		*D'')))Ds!(
A7AA22A7c|jr6|jd}||jzSdS)zk
        Flushes the decoder. Should only be called if the decoder is actually
        being used.
        r)r~r.rQ)r"bufs  r#rzHTTPResponse._flush_decodersA
=	/-**3//C,,....src#*Kd}		dVn#t$rt|jddt$r;}dt	|vrt|t|jddd}~wttf$r}td|z|d}~wwxYwd}|s@|j	r|j	
|jr|j
|j	r/|j	r|
dSdSdS#|s@|j	r|j	
|jr|j
|j	r.|j	r|
wwwxYw)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 
L
L
L'tz49JKKK
L
L
L-SVV;;"1++%&tz49JKKK!;/
D
D
D#$;a$?CCC
DJ
-*4+11333
#-$**,,,&
$4+B+K+K+M+M
$!!#####
$
$
$
$
-*4+11333
#-$**,,,&
$4+B+K+K+M+M
$!!####
$
$s2D)B6A++B?BBDA:Fc|||j}|jdSd}t|jdd}|5| |s|jnd}d}nmd}|s|j|nd}|dkrG|sE|jd}|jr#|jdvrt|j
|jdddn#1swxYwY|ra|xj
t|z
c_
|j|xjt|zc_||||}|r||_
|S)aT
        Similar to :meth:`http.client.HTTPResponse.read`, but with two additional
        parameters: ``decode_content`` and ``cache_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.

        :param cache_content:
            If True, will save the returned data such that the same result is
            returned despite of the state of the underlying file object. This
            is useful if you want the ``.data`` property to continue working
            after having ``.read()`` the file object. (Overridden if ``amt`` is
            set.)
        NFclosedrTr)rN)rrtrr(rrnrr|rrrrrr)r"amtrtrr	fp_closedr0s       r#rnzHTTPResponse.reads*	
!!0N8F
DHh66	

 
 
"
"	Y	Y{.7@tx}}S $

 %
1:Ctx}}S)))1HHTHHNN$$$$(M2	Yt7LU88-T-@$BWXXX;	Y	Y	Y	Y	Y	Y	Y	Y	Y	Y	Y	Y	Y	Y	Y>	"3t99,$0%%T2%%<<nmDDD
"!
sBC//C36C3c#K|jr4|r |||D]}|VdSt|js3|||}|r|Vt|j1dSdS)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.
        rs)rrtN)rrsupports_chunked_readsread_chunkedrrrn)r"rrtliner0s     r#streamzHTTPResponse.stream+s <	D7799	))#n)MM







#48,,
yySyHHJJJ	#48,,




rc"|j}t|tsBtjrtj|}n!t|}t|dd}|d|||j|j	|j
||d|}|S)a
        Given an :class:`http.client.HTTPResponse` instance ``r``, return a
        corresponding :class:`urllib3.response.HTTPResponse` object.

        Remaining parameters are passed to the HTTPResponse constructor, along
        with ``original_response=r``.
        rzr)rrvrwrxryrzrr6)rrurrPY2from_httplibitemsr(rwrxry)ResponseClsrresponse_kwrvrzresps      r#rzHTTPResponse.from_httplibEs%'>22	:w
:(5g>>(99Ha(({	
8I8	
	
	
	
rc|jSr&rvr!s r#
getheaderszHTTPResponse.getheadersf
|rc8|j||Sr&)rvr)r"r*defaults   r#	getheaderzHTTPResponse.getheaderis|g...rc|jSr&rr!s r#infozHTTPResponse.infomrrc|js|j|jr|j|js!t
j|dSdSr&)rrrrr}ioIOBaser!s r#rzHTTPResponse.closeqsl{	HNN	%""$$$	"IOOD!!!!!	"	"rc|js$tjj|S|jdSt
|jdr|jSt
|jdr|jjSdS)NTrr)r}rrr__get__rrNrr!s r#rzHTTPResponse.closed{s}		9#++D111
X
4
TXz
*
*	8$$&&&
TXx
(
(	8?"4rc|jtdt|jdr|jStd)Nz-HTTPResponse has no file to get a fileno fromfilenozOThe file-like object this HTTPResponse is wrapped around has no file descriptor)rIOErrorrNrr!s r#rzHTTPResponse.filenosV8IJJJ
TXx
(
(	8??$$$0
rc|jDt|jdr1t|jdds|jSdSdSdS)NrQrF)rrNr(rQr!s r#rQzHTTPResponse.flushs\H '**
!DHh66
!8>>###	
!     rcdS)NTr6r!s r#readablezHTTPResponse.readablestrc|t|}t|dkrdS||dt|<t|Sr`)rnr)r"btemps   r#readintozHTTPResponse.readintosLyyQ  t99>>1!AkD		kNt99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)rNrr!s r#rz#HTTPResponse.supports_chunked_readsstx&&&rc|jdS|jj}|ddd}	t|d|_dS#t$r%|t||wxYw)N;rrr@)	rrrreadliner\rrrr)r"rs  r#_update_chunk_lengthz!HTTPResponse._update_chunk_lengths?&Fx{##%%zz$""1%	1!$mmDOOO	1	1	1JJLLL$T4000	1sA/Bcd}|C|j|j}|}|jdd|_n||jkr,|j|}|j|z
|_|}n||jkr>|j|}|jdd|_|}n@|j|j}|jdd|_|S)Nr9)r
_safe_readr)r"rreturned_chunkchunkvalues     r#
_handle_chunkzHTTPResponse._handle_chunks;H''88E"NH""""DOO
4?
"
"H'',,E"o3DO"NN
DO
#
#H'',,EH""""DO"NN!X00AANH""""DOrc#,K||jstd|st	d|5|jr;t|jr'|j	ddddS|j	j
	ddddS	||jdkrn4|
|}|||d}|r|VT|r|}|r|V	|j	j
}|sn|dkrn)|jr|jddddS#1swxYwYdS)	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.NTrF)rtrs
)rrrrrrrrrrrrrrrrrr)r"rrtrdecodedrs      r#rzHTTPResponse.read_chunkedso	
|	$B
**,,	*P


 
 
"
")	0)	0&
+>t?V+W+W
'--///	)	0)	0)	0)	0)	0)	0)	0)	0x{")	0)	0)	0)	0)	0)	0)	0)	0	
"))+++?a''**3//,,.'"!MMM	
"
"--//"!MMM
x{++--7??

&
0'--///S)	0)	0)	0)	0)	0)	0)	0)	0)	0)	0)	0)	0)	0)	0)	0)	0)	0)	0s$6F	'
F	B;F		F
F
c~|j0t|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.
        N)r{rhistoryredirect_locationrr!s r#geturlzHTTPResponse.geturls:<#DL,@(A(A#<'+==$$rc#jKg}|dD]|}d|vra|d}d||dzdzV|ddD]	}|dzV
|dr
|dg}dg}g||}|rd|VdSdS)NTrs
rrrr)rr\joinappend)r"bufferrxs    r#__iter__zHTTPResponse.__iter__&s[[[55	%	%E~~E**hhv&&q1E9999qt$$Ae)OOOO9 #Bi[FFFF

e$$$$	#((6"""""""	#	#r)rlNrrNrTTNNNNNFNNT)NNF)rNr&)NN)-r3r4r5rdrrLrr$rrrpropertyr0rrrrrrrrrrrrrrnrclassmethodrrrrrrrrQrrrrrrrrr6rr#rjrjs@	*
TF"111
$%ABABABABF   			11X1  X &&&###222hCCC&%dj1
&,0,			5$5$^5$nHHHHT4[@////"""

X
			$$$'''111,D0D0D0D0L	%	%	%#####rrj)/
__future__rrloggingr
contextlibrsocketrrrrrLImportError_collectionsrrr	r

exceptionsrrr
rrrrrrrpackagesr
util.responserr	getLoggerr3robjectrr8r>rJrSrVrrjr6rr#<module>rs&&&&&&				%%%%%%''''''++++++MMMM
FFF)(((((33333333<<<<<<<<g!!"""""V"""@v@@@@@&@@@<
"6*


X
#X
#X
#X
#X
#29X
#X
#X
#X
#X
#s+55
Back to Directory File Manager