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



]judZddlZddlZddlZddlmZddlmZddlm	Z	ddl
mZmZm
Z
mZmZddlmZmZmZmZdd	lmZmZmZdd
lmZmZddlmZddlmZm Z m!Z!dd
l"m#Z#m$Z$m%Z%m&Z&ddl'm(Z(ddl)m*Z*ddlm+Z+m,Z,m-Z-m.Z.m/Z/m0Z0ddl1m2Z2ddlm3Z3ej4dkr	ej5Z6n#e7$r
ej8Z6YnwxYwejZ6efdZ9efdZ:Gdde;Z<Gdde<Z=dZ>dS)z
requests.sessions
~~~~~~~~~~~~~~~~~

This module provides a Session object to manage and persist settings across
requests (cookies, auth, proxies).
N)	timedelta)OrderedDict)_basic_auth_str)	cookielibis_py3urljoinurlparseMapping)cookiejar_from_dictextract_cookies_to_jarRequestsCookieJar
merge_cookies)RequestPreparedRequestDEFAULT_REDIRECT_LIMIT)
default_hooks
dispatch_hook)to_native_string)to_key_val_listdefault_headers
DEFAULT_PORTS)TooManyRedirects
InvalidSchemaChunkedEncodingErrorContentDecodingError)CaseInsensitiveDict)HTTPAdapter)requote_uriget_environ_proxiesget_netrc_authshould_bypass_proxiesget_auth_from_urlrewind_body)codes)REDIRECT_STATIwin32c.||S||St|trt|ts|S|t|}|t|d|D}|D]}||=|S)zDetermines appropriate setting for a given request, taking into account
    the explicit setting on that request, and the setting in the session. If a
    setting is a dictionary, they will be merged together using `dict_class`
    Ncg|]	\}}||
SN).0kvs   q/builddir/build/BUILD/imunify360-venv-2.6.3/opt/imunify360/venv/lib/python3.11/site-packages/requests/sessions.py
<listcomp>z!merge_setting.<locals>.<listcomp>JsEEEv119999)
isinstancerrupdateitems)request_settingsession_setting
dict_classmerged_setting	none_keyskeys      r/
merge_settingr;2s
0000Z @ @AAN//::;;;FE!5!5!7!7EEEI  3r1c||dgkr|S||dgkr|St|||S)zProperly merges both requests and session hooks.

    This is necessary because when request_hooks == {'response': []}, the
    merge breaks Session hooks entirely.
    Nresponse)getr;)
request_hooks
session_hooksr7s   r/merge_hooksrAQs^
 1 1* = = C C
 1 1* = = C C
zBBBr1c8eZdZdZdZ		d
dZdZdZd	ZdS)SessionRedirectMixinc|jr9|jd}tr|d}t	|dSdS)z7Receives a Response. Returns a redirect URI or ``None``locationlatin1utf8N)is_redirectheadersrencoder)selfresprEs   r/get_redirect_targetz(SessionRedirectMixin.get_redirect_targetbsK
	6|J/H
5#??844#Hf555tr1cbt|}t|}|j|jkrdS|jdkr|jdvr|jdkr|jdvrdS|j|jk}|j|jk}t	j|jddf}|s|j|vr|j|vrdS|p|S)zFDecide whether Authorization header should be removed when redirectingThttp)PNhttps)iNFN)r
hostnameschemeportrr>)rKold_urlnew_url
old_parsed
new_parsedchanged_portchanged_schemedefault_ports        r/should_strip_authz&SessionRedirectMixin.should_strip_authwsg&&
g&&
*"5554

''JOz,I,I%00Z_5S5S5"*/9#*j.??%)**;TBBDI	:?l#B#BO|335-~-r1FNTc	
+Kg}
||}t|jj}|r6|}
|
||
dd|_	|jn8#tttf$r|jdYnwxYwt|j|jkr)td|j|||dr=t|j}dt)|j|g}t|}|jd	kr|r||
}n|jr|j}|}|js#t3|jt5|}nt5|}t)||
_||
||jt:jt:jfvr)d}|D]}|
j !|dd|
_"|
j }|!ddtG|
j$||jtK|
j$|j&|
'|
j$|(|
|}|)|
||
j*duod
|vpd|v}|rtW|
|
}|r|VnI|j,|f|||||dd|	}tG|j&|
|j||}|V|4dSdS)zBReceives a Response. Returns a generator of Responses or Requests.rNF)decode_contentzExceeded {} redirects.)r=z//:)fragment)Content-LengthzContent-TypeTransfer-EncodingCookierbrc)streamtimeoutverifycertproxiesallow_redirects)-rMr
urlracopyappendhistorycontentrrRuntimeErrorrawreadlen
max_redirectsrformatclose
startswithjoinrrS_replacegeturlnetlocr	rrebuild_methodstatus_coder%temporary_redirectpermanent_redirectrIpopbodyr
_cookiesrcookiesprepare_cookiesrebuild_proxiesrebuild_auth_body_positionr$send)rKrLreqrerfrgrhriyield_requestsadapter_kwargshistrkprevious_fragmentprepared_requestparsed_rurlparsedpurged_headersheaderrI
rewindables                    r/resolve_redirectsz&SessionRedirectMixin.resolve_redirectss&&t,,$SW--6d	"xxzz
KK8DL
4(*>M
4
4
4

U
33333
44<  D$666&'?'F'FtGY'Z'Zeijjjj
JJLLL~~d##
L&tx00hh 01C D DcJKKc]]F"$$):$2CDD
4$*O!--//C
=
'dhC(8(899!#&&#3C#8#8  0$777(@%BZ'[[[!X,??F$,00>>>>(, %&.GKK$'''

##3#<c48LLL*3T\BBB,,-=-FGGG**+;WEEG.555!/t;P!W,N0Cw0N

.,---#C
				!ty	!#!#$)		%		't|5EtxPPP..t44


Id	d	d	d	d	s/A772B,+B,c|j}|j}d|vr#||jj|r|d=|jrt|nd}|||dSdS)zWhen being redirected we may want to strip authentication from the
        request to avoid leaking credentials. This method intelligently removes
        and reapplies authentication where possible to avoid credential loss.
        
AuthorizationN)rIrkr\request	trust_envr!prepare_auth)rKrr=rIrknew_auths      r/rz!SessionRedirectMixin.rebuild_auths
#*"g%%$*@*@AQAUWZ*[*[%(+/.B>#&&&d))(33333 r1c||ni}|j}|j}t|j}|}|d}t
||}|jrT|sRt||}	|	||	d}
|
r|	||
d|vr|d=	t||\}}n#t$rd\}}YnwxYw|r|rt|||d<|S)aThis method re-evaluates the proxy configuration by considering the
        environment variables. If we are redirected to a URL covered by
        NO_PROXY, we strip the proxy configuration. Otherwise, we set missing
        proxy keys for this URL (in case they were stripped by a previous
        redirect).

        This method also replaces the Proxy-Authorization header where
        necessary.

        :rtype: dict
        Nno_proxyrallzProxy-AuthorizationNN)
rIrkr
rSrlr>r"rr 
setdefaultr#KeyErrorr)
rKrrirIrkrSnew_proxiesrbypass_proxyenviron_proxiesproxyusernamepasswords
             r/rz$SessionRedirectMixin.rebuild_proxiessM%0''b"*"#%llnn;;z**,S8DDD>	6,	61#IIIO#''0C0CE0J0JKKE
6&&vu555 G++-.	,!2;v3F!G!GHhh	,	,	,!+Hhhh	,	Q	Q-<Xx-P-PG)*sCC10C1c|j}|jtjkr|dkrd}|jtjkr|dkrd}|jtjkr|dkrd}||_dS)zWhen being redirected we may want to change the method of the request
        based on certain specs or browser behavior.
        HEADGETPOSTN)methodr}r%	see_otherfoundmoved)rKrr=rs    r/r|z#SessionRedirectMixin.rebuild_method:s~"(5?22v7G7GF5;..6V3C3CF5;..6V3C3CF"(r1)FNTNNF)	__name__
__module____qualname__rMr\rrrr|r+r1r/rCrC`s*...2BFOTllll\444&'''R)))))r1rCceZdZdZgdZdZdZdZdZ			dd	Z	d
Z
dZdZdd
Z
ddZddZdZdZdZdZdZdZdZdZdS)SessionaA Requests session.

    Provides cookie persistence, connection-pooling, and configuration.

    Basic Usage::

      >>> import requests
      >>> s = requests.Session()
      >>> s.get('https://httpbin.org/get')
      <Response [200]>

    Or as a context manager::

      >>> with requests.Session() as s:
      ...     s.get('https://httpbin.org/get')
      <Response [200]>
    )rIrauthrihooksparamsrgrhadaptersrerrtct|_d|_i|_t	|_i|_d|_d|_d|_	t|_d|_ti|_t|_|dt%|dt%dS)NFTzhttps://zhttp://)rrIrrirrrrergrhrrtrrrrrmountrrKs r/__init__zSession.__init__js
'((	
#__

	4+2..$




:{}}---

9kmm,,,,,r1c|Sr*r+rs r/	__enter__zSession.__enter__sr1c.|dSr*)rv)rKargss  r/__exit__zSession.__exit__s

r1c|jpi}t|tjst	|}ttt
|j|}|j}|jr|s|jst|j
}t}||j
|j
|j|j|jt%|j|jt(t%|j|jt%||j|t-|j|j

|S)aConstructs a :class:`PreparedRequest <PreparedRequest>` for
        transmission and returns it. The :class:`PreparedRequest` has settings
        merged from the :class:`Request <Request>` instance and those of the
        :class:`Session`.

        :param request: :class:`Request` instance to prepare with this
            session's settings.
        :rtype: requests.PreparedRequest
        )r7)
rrkfilesdatajsonrIrrrr)rr2r	CookieJarrrrrrr!rkrpreparerupperrrrr;rIrrrAr)rKrrmerged_cookiesrps      r/prepare_requestzSession.prepare_requests./'R'9#677	3)'22G'+--t|<<gGG|>	/$	/ty	/!'+..D			>''))-!'/4<L_``` ==tTY//"gmTZ88		
	
	
r1NTc"t|||||pi||pi|||

}||}|pi}||j||
||}|	|
d}|||j|fi|}|S)ax	Constructs a :class:`Request <Request>`, prepares it and sends it.
        Returns :class:`Response <Response>` object.

        :param method: method for the new :class:`Request` object.
        :param url: URL for the new :class:`Request` object.
        :param params: (optional) Dictionary or bytes to be sent in the query
            string for the :class:`Request`.
        :param data: (optional) Dictionary, list of tuples, bytes, or file-like
            object to send in the body of the :class:`Request`.
        :param json: (optional) json to send in the body of the
            :class:`Request`.
        :param headers: (optional) Dictionary of HTTP Headers to send with the
            :class:`Request`.
        :param cookies: (optional) Dict or CookieJar object to send with the
            :class:`Request`.
        :param files: (optional) Dictionary of ``'filename': file-like-objects``
            for multipart encoding upload.
        :param auth: (optional) Auth tuple or callable to enable
            Basic/Digest/Custom HTTP Auth.
        :param timeout: (optional) How long to wait for the server to send
            data before giving up, as a float, or a :ref:`(connect timeout,
            read timeout) <timeouts>` tuple.
        :type timeout: float or tuple
        :param allow_redirects: (optional) Set to True by default.
        :type allow_redirects: bool
        :param proxies: (optional) Dictionary mapping protocol or protocol and
            hostname to the URL of the proxy.
        :param stream: (optional) whether to immediately download the response
            content. Defaults to ``False``.
        :param verify: (optional) Either a boolean, in which case it controls whether we verify
            the server's TLS certificate, or a string, in which case it must be a path
            to a CA bundle to use. Defaults to ``True``. When set to
            ``False``, requests will accept any TLS certificate presented by
            the server, and will ignore hostname mismatches and/or expired
            certificates, which will make your application vulnerable to
            man-in-the-middle (MitM) attacks. Setting verify to ``False`` 
            may be useful during local development or testing.
        :param cert: (optional) if String, path to ssl client cert file (.pem).
            If Tuple, ('cert', 'key') pair.
        :rtype: requests.Response
        )
rrkrIrrrrrrr)rfrj)rrrmerge_environment_settingsrkr3r)rKrrkrrrIrrrrfrjrirrergrhrrprepsettingssend_kwargsrLs                      r/rzSession.requests\<<>><R


##C((-R22Hgvvt

.

	8$$$ty----r1cL|dd|jd|fi|S)zSends a GET request. Returns :class:`Response` object.

        :param url: URL for the new :class:`Request` object.
        :param \*\*kwargs: Optional arguments that ``request`` takes.
        :rtype: requests.Response
        rjTrrrrKrkkwargss   r/r>zSession.get"s7	+T222t|E311&111r1cL|dd|jd|fi|S)zSends a OPTIONS request. Returns :class:`Response` object.

        :param url: URL for the new :class:`Request` object.
        :param \*\*kwargs: Optional arguments that ``request`` takes.
        :rtype: requests.Response
        rjTOPTIONSrrs   r/optionszSession.options-s7	+T222t|Is55f555r1cL|dd|jd|fi|S)zSends a HEAD request. Returns :class:`Response` object.

        :param url: URL for the new :class:`Request` object.
        :param \*\*kwargs: Optional arguments that ``request`` takes.
        :rtype: requests.Response
        rjFrrrs   r/headzSession.head8s7	+U333t|FC226222r1c&|jd|f||d|S)aSends a POST request. Returns :class:`Response` object.

        :param url: URL for the new :class:`Request` object.
        :param data: (optional) Dictionary, list of tuples, bytes, or file-like
            object to send in the body of the :class:`Request`.
        :param json: (optional) json to send in the body of the :class:`Request`.
        :param \*\*kwargs: Optional arguments that ``request`` takes.
        :rtype: requests.Response
        r)rrr)rKrkrrrs     r/postzSession.postCs't|FCHdHHHHHr1c$|jd|fd|i|S)auSends a PUT request. Returns :class:`Response` object.

        :param url: URL for the new :class:`Request` object.
        :param data: (optional) Dictionary, list of tuples, bytes, or file-like
            object to send in the body of the :class:`Request`.
        :param \*\*kwargs: Optional arguments that ``request`` takes.
        :rtype: requests.Response
        PUTrrrKrkrrs    r/putzSession.putPs%t|E3<<T<V<<<r1c$|jd|fd|i|S)awSends a PATCH request. Returns :class:`Response` object.

        :param url: URL for the new :class:`Request` object.
        :param data: (optional) Dictionary, list of tuples, bytes, or file-like
            object to send in the body of the :class:`Request`.
        :param \*\*kwargs: Optional arguments that ``request`` takes.
        :rtype: requests.Response
        PATCHrrrs    r/patchz
Session.patch\s%t|GS>>t>v>>>r1c |jd|fi|S)zSends a DELETE request. Returns :class:`Response` object.

        :param url: URL for the new :class:`Request` object.
        :param \*\*kwargs: Optional arguments that ``request`` takes.
        :rtype: requests.Response
        DELETErrs   r/deletezSession.deletehs t|Hc44V444r1cH|d|j|d|j|d|j|d|||jt
|trtd|	dd}|
d}|j}||j
}t}|j|fi|}t|z
}	t!|		|_t%d
||fi|}|jr*|jD]"}
t)|j|
j|
j#t)|j||j|r|j||fi|}d|D}ng}|r1|d||	}||_|s5	t5|j||fd
di||_n#t8$rYnwxYw|s|j|S)zISend a given PreparedRequest.

        :rtype: requests.Response
        rergrhriz#You can only send PreparedRequests.rjT)rk)secondsr=cg|]}|Sr+r+)r,rLs  r/r0z Session.send.<locals>.<listcomp>s,,,t,,,r1rr)rrergrhrrir2r
ValueErrorrr>rget_adapterrkpreferred_clockrrelapsedrrnr
rrrqrinsertnext_next
StopIterationro)
rKrrrjreradapterstartrrrLgenrns
             r/rzSession.sendrs	(DK000(DK000&$),,,)T%9%9'4<%P%PQQQgw''	DBCCC!**%6==H%%
""w{"33 !!
GL++F++"##e+g...	
*eQ99&99
9	M	
M
M&t|T\48LLLLt|Wae<<<	($(G>>v>>C,,,,,GGG	 NN1a   

AAI	
5t5a``QU`Y_``aa 



	
IIs%#H		
HHc|jr||dnd}t||}|D]\}}	|||	|dus|>t
jdpt
jd}t||j}t||j	}t||j
}t||j}||||dS)z^
        Check the environment and merge it with some settings.

        :rtype: dict
        NrrTREQUESTS_CA_BUNDLECURL_CA_BUNDLE)rgrirerh)rr>r r4rosenvironr;rirergrh)
rKrkrirergrhrenv_proxiesr-r.s
          r/rz"Session.merge_environment_settingss>	<292Ew{{:...4H-cHEEEK%++--
)
)A""1a((((~~*..)=>>;*..)9:: 66vt{33vt{33T49-- W	r1c|jD]B\}}||r|cSCt	d|)z~
        Returns the appropriate connection adapter for the given URL.

        :rtype: requests.adapters.BaseAdapter
        z*No connection adapters were found for {!r})rr4lowerrwrru)rKrkprefixrs    r/rzSession.get_adaptersz"&!4!4!6!6		VWyy{{%%fllnn55

HOOPSTTUUUr1cf|jD]}|dS)z+Closes all adapters and as such the sessionN)rvaluesrv)rKr.s  r/rvz
Session.closes8%%''		A
GGIIII		r1c||j<fd|jD}|D]$}|j||j|<%dS)zwRegisters a connection adapter to a prefix.

        Adapters are sorted in descending order by prefix length.
        cTg|]$}t|tk"|%Sr+)rs)r,r-rs  r/r0z!Session.mount.<locals>.<listcomp>s/IIIaCFFS[[4H4H4H4H4Hr1N)rr)rKrrkeys_to_mover:s `   r/rz
Session.mountsd
!(
fIIII4=III	8	8C!%!2!23!7!7DM#	8	8r1c.fdjD}|S)Nc4i|]}|t|dSr*)getattr)r,attrrKs  r/
<dictcomp>z(Session.__getstate__.<locals>.<dictcomp>s'LLLTwtT400LLLr1)	__attrs__)rKstates` r/__getstate__zSession.__getstate__s#LLLLT^LLLr1c\|D]\}}t|||dSr*)r4setattr)rKr
rvalues    r/__setstate__zSession.__setstate__s< ;;==	'	'KD%D$&&&&	'	'r1)NNNNNNNTNNNNNNrr*)rrr__doc__r	rrrrrr>rrrrrrrrrrvrrrr+r1r/rrQs$I<-<-<-|&&&RGKCGBFJJJJX	2	2	2	6	6	6	3	3	3IIII
=
=
=
=
?
?
?
?555IIIV:VVV
	8	8	8'''''r1rctS)aZ
    Returns a :class:`Session` for context-management.

    .. deprecated:: 1.0.0

        This method has been deprecated since version 1.0.0 and is only kept for
        backwards compatibility. New code should use :class:`~requests.sessions.Session`
        to create a session. This may be removed at a future date.

    :rtype: Session
    )rr+r1r/sessionrs99r1)?rrsystimedatetimercollectionsrrrcompatrrr	r
rrrr
rrmodelsrrrrrr_internal_utilsrutilsrrr
exceptionsrrrr
structuresrrrrr r!r"r#r$status_codesr%r&platformperf_counterrAttributeErrorclockr;rAobjectrCrrr+r1r/<module>r#s&
			



######!!!!!!AAAAAAAAAAAAAASSSSSSSSSSSSDDDDDDDDDD////////------BBBBBBBBBBQQQQQQQQQQQQ,+++++!!!!!!
 #"""""<7%+%%%*%iO@K>:ECCCCn)n)n)n)n)6n)n)n)bm'm'm'm'm'"m'm'm'`
sB%%B43B4
Back to Directory File Manager