8fRdZddlZddlZddlmZddlmZmZm Z m Z m Z ddl m Z ddlmZddlmZdd lmZmZdd lmZdd lmZmZmZmZmZmZmZdd lmZ dd lm!Z!m"Z"m#Z#ddl$m%Z%m&Z&m'Z'ddl(m)Z)m*Z*m+Z+m,Z,m-Z-m.Z.ddl(mZ/ddl(m0Z0ddl(m Z1ddl(m2Z2ddl3m4Z4ddl5m6Z6ddl7m8Z8ddl9m:Z:m;Z;mZ>m?Z?m@Z@mAZAmBZBmCZCe6jDe6jEe6jFe6jGe6jHfZIdZJdZKdZLGddZMGddZNGdd eNZOGd!d"eMeNZPGd#d$ZQdS)%z` requests.models ~~~~~~~~~~~~~~~ This module contains the primary objects that power Requests. N)UnsupportedOperation) DecodeErrorLocationParseError ProtocolErrorReadTimeoutErrorSSLError) RequestField)encode_multipart_formdata) parse_url)to_native_stringunicode_is_ascii) HTTPBasicAuth)CallableJSONDecodeErrorMapping basestring builtin_strchardet cookielib)json) urlencodeurlsplit urlunparse)_copy_cookie_jarcookiejar_from_dictget_cookie_header)ChunkedEncodingErrorConnectionErrorContentDecodingError HTTPErrorInvalidJSONError InvalidURL)r) MissingSchema)r)StreamConsumedError) default_hooks)codes)CaseInsensitiveDict) check_header_validityget_auth_from_urlguess_filenameguess_json_utf iter_slicesparse_header_links requote_uristream_decode_response_unicode super_lento_key_val_listi(icPeZdZedZedZedZdS)RequestEncodingMixincg}t|j}|j}|sd}|||j}|r*|d||d|S)zBuild the path URL to use./?)rurlpathappendqueryjoin)selfr:pr;r=s {/builddir/build/BUILD/imunify360-venv-2.3.5/opt/imunify360/venv/lib/python3.11/site-packages/pip/_vendor/requests/models.pypath_urlzRequestEncodingMixin.path_urlUs~ TX  v D 4   JJsOOO JJu   wws||c  t|ttfr|St|dr|St|drg}t |D]\}}t|t st|ds|g}|D]o}|k|t|tr|dn|t|tr|dn|fpt|dS|S)zEncode parameters in a piece of data. Will successfully encode parameters when passed as a dict or a list of 2-tuples. Order is retained if data is a list of 2-tuples but arbitrary if parameters are supplied as a dict. read__iter__Nutf-8T)doseq) isinstancestrbyteshasattrr2rr<encoder)dataresultkvsvs rA_encode_paramsz#RequestEncodingMixin._encode_paramsjs' dS%L ) ) K T6 " " K T: & & F(..  2b*--WR5L5LBA} 5?35G5G N 1 1 1Q5?35G5G N 1 1 1QV4000 0KrCc v|stdt|trtdg}t|pi}t|pi}|D]\}}t|tst |ds|g}|D]}|t|t st |}|t|t r|dn|t|t r| dn|f|D]\}}d}d} t|ttfr;t|dkr|\} } n5t|dkr|\} } }n|\} } }} nt|p|} |} t| t t tfr| } n*t | dr| } n| | } t!|| | | } | | || t%|\}}||fS) aBuild the body for a multipart/form-data request. Will successfully encode files when passed as a dict or a list of tuples. Order is retained if data is a list of tuples but arbitrary if parameters are supplied as a dict. The tuples may be 2-tuples (filename, fileobj), 3-tuples (filename, fileobj, contentype) or 4-tuples (filename, fileobj, contentype, custom_headers). zFiles must be provided.zData must not be a string.rFNrGrE)namerNfilenameheaders) content_type) ValueErrorrIrr2rLrKrJr<decoderMtuplelistlenr+ bytearrayrEr make_multipartr )filesrN new_fieldsfieldsfieldvalrRrPftfhfnfpfdatarfbodyrZs rA _encode_filesz"RequestEncodingMixin._encode_filess ;677 7 j ) ) ;9:: :  ,, ,,   JE3#z** '#z2J2J e  =%a//#FF%% *%77'ELL111!&1;As1C1CJAHHW---   " "DAqBB!eT]++ q66Q;;FBVVq[[!"JBBB%&NBB#A&&+!"sE9566 V$$  152rJJJB   2  . . .   b ! ! ! !6zBBl\!!rCN)__name__ __module__ __qualname__propertyrB staticmethodrSrnrCrAr5r5Tsh X(\:B"B"\B"B"B"rCr5ceZdZdZdZdS)RequestHooksMixinc$||jvrtd|dt|tr"|j||dSt |dr,|j|d|DdSdS)zProperly register a hook.z.Unsupported event specified, with event name ""rFc3DK|]}t|t|VdSN)rIr).0hs rA z2RequestHooksMixin.register_hook..s1$P$P1 1h8O8O$PQ$P$P$P$P$P$PrCN)hooksr[rIrr<rLextendr?eventhooks rA register_hookzRequestHooksMixin.register_hooks  " "VeVVVWW W dH % % Q Ju  $ $T * * * * * T: & & Q Ju  $ $$P$P$P$P$P P P P P P Q QrCcj |j||dS#t$rYdSwxYw)ziDeregister a previously registered hook. Returns True if the hook existed, False if not. TF)r~remover[rs rAderegister_hookz!RequestHooksMixin.deregister_hooksI   Ju  $ $T * * *4   55 s $ 22N)rorprqrrrtrCrArvrvs5 Q Q Q     rCrvc:eZdZdZ ddZdZdZdS)Requesta{A user-created :class:`Request ` object. Used to prepare a :class:`PreparedRequest `, which is sent to the server. :param method: HTTP method to use. :param url: URL to send. :param headers: dictionary of headers to send. :param files: dictionary of {filename: fileobject} files to multipart upload. :param data: the body to attach to the request. If a dictionary or list of tuples ``[(key, value)]`` is provided, form-encoding will take place. :param json: json for the body to attach to the request (if files or data is not specified). :param params: URL parameters to append to the URL. If a dictionary or list of tuples ``[(key, value)]`` is provided, form-encoding will take place. :param auth: Auth handler or (user, pass) tuple. :param cookies: dictionary or CookieJar of cookies to attach to this request. :param hooks: dictionary of callback hooks, for internal usage. Usage:: >>> import requests >>> req = requests.Request('GET', 'https://httpbin.org/get') >>> req.prepare() Nc b|gn|}|gn|}|in|}|in|}| in| } t|_t| D]\} } || | ||_||_||_||_||_ | |_ ||_ ||_ ||_ dS)N)rr)r&r~r^itemsrmethodr:rYrbrNrparamsauthcookies) r?rr:rYrbrNrrrr~rrPrRs rA__init__zRequest.__init__s\rrtm""W~6m"__ '' 0 0DAq   QQ  / / / /        rCcd|jdS)Nz rr?s rA__repr__zRequest.__repr__$s+DK++++rCc t}||j|j|j|j|j|j|j|j |j |j  |S)zXConstructs a :class:`PreparedRequest ` for transmission and returns it.) rr:rYrbrNrrrrr~) PreparedRequestpreparerr:rYrbrNrrrrr~r?r@s rArzRequest.prepare'sa    ;L*;L*  rC NNNNNNNNNN)rorprq__doc__rrrrtrCrArrsq:        D,,,rCrceZdZdZdZ ddZdZdZdZe dZ d Z d Z dd Z d ZddZdZdZdS)ra)The fully mutable :class:`PreparedRequest ` object, containing the exact bytes that will be sent to the server. Instances are generated from a :class:`Request ` object, and should not be instantiated manually; doing so may produce undesirable effects. Usage:: >>> import requests >>> req = requests.Request('GET', 'https://httpbin.org/get') >>> r = req.prepare() >>> r >>> s = requests.Session() >>> s.send(r) cd|_d|_d|_d|_d|_t |_d|_dSrz)rr:rY_cookiesrmr&r~_body_positionrs rArzPreparedRequest.__init__Ns@    "__ "rCNc 4||||||||||||| ||||| dS)z6Prepares the entire request with the given parameters.N)prepare_method prepare_urlprepare_headersprepare_cookies prepare_body prepare_auth prepare_hooks) r?rr:rYrbrNrrrr~rs rArzPreparedRequest.prepare_s F### f%%% W%%% W%%% $t,,, $$$$ 5!!!!!rCcd|jdS)Nz+>??DKKK # "rCcddlm} ||dd}n#|j$rt wxYw|S)Nr)idnaT)uts46rG) pip._vendorrrMr\ IDNAError UnicodeError)hostrs rA_get_idna_encoded_hostz&PreparedRequest._get_idna_encoded_hostsf$$$$$$ ;;t4;0077@@DD~      s *3Ac t|tr|d}nt|}|}d|vr0|ds ||_dS t|\}}}}}}} n #t$r} t| j d} ~ wwxYw|std|d|d|std|dt|s4 ||}nA#t$rtd wxYw|d rtd |pd } | r| d z } | |z } |r| d|z } |sd }t|ttfrt!|}||} | r |r|d| }n| }t%t'|| |d|| g}||_dS)zPrepares the given HTTP URL.utf8:httpNz Invalid URL z0: No scheme supplied. Perhaps you meant https://r8z: No host suppliedzURL has an invalid label.)*.r9@r7&)rIrKr\rJlstriplower startswithr:r rr#argsr$rrrr rSr/r) r?r:rschemerrportr;r=fragmentenetloc enc_paramss rArzPreparedRequest.prepare_urlsw c5 ! ! **V$$CCc((Cjjll #::ciikk44V<<:DH F &>Gnn ;FD$dE88! & & &af% % & 4s44-0444   GECEEEFF F  %% : >22488 > > > !<=== > __Z ( ( :899 9   cMF$  ! j$jj F D fsEl + + .%f--F((00  # # //://"*ffdD%%RSSTTs$B B9&B44B99DD)ct|_|rB|D]/}t||\}}||jt |<.dSdS)z Prepares the given HTTP headers.N)r(rYrr)r )r?rYheaderrWvalues rArzPreparedRequest.prepare_headersss+,,  =!--// = =%f---$ e7< -d3344  = = = =rCc d}d}|si|gd} tj|d}n##t$r}t||d}~wwxYwt |t s|d}tt|dt |ttttf g}|r t|}n#ttt f$rd}YnwxYw|}t#|dd> ||_n##t($rt+|_YnwxYw|rt-d |rt/||jd <nd |jd <n|r|||\}}nA|r?||}t |tst|d rd}nd}|||rd|jvr ||jd<||_dS)z"Prepares the given HTTP body data.Nzapplication/jsonF) allow_nan)requestrGrFtellz1Streamed bodies and files are mutually exclusive.Content-LengthchunkedzTransfer-EncodingrEz!application/x-www-form-urlencodedz content-typez Content-Type) complexjsondumpsr[r"rIrKrMallrLrr^r]rr1 TypeErrorAttributeErrorrgetattrrrOSErrorobjectNotImplementedErrorrrYrnrSprepare_content_lengthrm) r?rNrbrrmrZve is_streamlengths rArzPreparedRequest.prepare_bodys}  ,(.L 9"(??? 9 9 9&r48888 9dE** ,{{7++j))tj$w%GHHH    , < "4~/CD    DtVT**63*.))++D''333+1((D'''3  )G >1A9C C%$C%<DD65D6c|,t|}|rt||jd<dSdS|jdvr&|jdd|jd<dSdSdS)z>Prepare Content-Length header based on request method and bodyNr)GETHEAD0)r1rrYrget)r?rmrs rArz&PreparedRequest.prepare_content_length<s  t__F E2=V1D1D -... E E K . .   !122:.1DL) * * * / .::rCr9cJ|'t|j}t|r|nd}|rwt|trt |dkr t |}||}|j|j| |j dSdS)z"Prepares the given HTTP auth data.NrU) r*r:anyrIr]r_r__dict__updaterrm)r?rr:url_authrs rArzPreparedRequest.prepare_authLs <(22H"8}}688$D  3$&& ,3t99>>$d+T A M  , , ,  ' ' 2 2 2 2 2 3 3rCct|tjr||_nt ||_t |j|}| ||jd<dSdS)aPrepares the given HTTP cookie data. This function eventually generates a ``Cookie`` header from the given cookies using cookielib. Due to cookielib's design, the header will not be regenerated if it already exists, meaning this function can only be called once for the life of the :class:`PreparedRequest ` object. Any subsequent calls to ``prepare_cookies`` will have no actual effect, unless the "Cookie" header is removed beforehand. NCookie)rIr CookieJarrrrrY)r?r cookie_headers rArzPreparedRequest.prepare_cookiesbsb gy2 3 3 9#DMM/88DM)$->>  $%2DL " " " % $rCcP|pg}|D]}||||dS)zPrepares the given hooks.N)r)r?r~rs rArzPreparedRequest.prepare_hooksvsC   4 4E   ueEl 3 3 3 3 4 4rCrrz)r9)rorprqrrrrrrrsrrrrrrrrrtrCrArr9s((###&    """"8444   @@@ \HHHT = = =LLLL\111 3333,333(44444rCrc(eZdZdZgdZdZdZdZdZdZ dZ d Z d Z d Z ed Zed ZedZedZedZddZeddfdZedZedZdZedZdZdZdS)ResponsezhThe :class:`Response ` object, which contains a server's response to an HTTP request. ) _content status_coderYr:historyencodingreasonrelapsedrcd|_d|_d|_d|_t |_d|_d|_d|_g|_ d|_ ti|_ tjd|_d|_dS)NFr)r_content_consumed_nextrr(rYrawr:rrrrrdatetime timedeltarrrs rArzResponse.__init__s !&   +,,    +2..  )!,,  rCc|Srzrtrs rA __enter__zResponse.__enter__s rCc.|dSrz)close)r?rs rA__exit__zResponse.__exit__s rCcFjsjfdjDS)Nc4i|]}|t|dSrz)r)r{attrr?s rA z)Response.__getstate__..s'KKKDgdD$//KKKrC)rcontent __attrs__rs`rA __getstate__zResponse.__getstate__s3%  LLKKKKDNKKKKrCc|D]\}}t|||t|ddt|dddS)NrTr)rsetattr)r?staterWrs rA __setstate__zResponse.__setstate__s_ ;;== ' 'KD% D$ & & & & )4000eT"""""rCcd|jdS)Nz ..PPrCcRd|jvo|jtjtjfvS)z@True if this Response one of the permanent versions of redirect.r)rYrr'moved_permanentlypermanent_redirectrs rAis_permanent_redirectzResponse.is_permanent_redirects4T\) d.>  #  $C /  rCc|jS)zTReturns a PreparedRequest for the next request in a redirect chain, if there is one.)rrs rAnextz Response.nexts zrCcRttj|jdSdS)zOThe apparent encoding, provided by the charset_normalizer or chardet libraries.NrrG)rdetectrrs rAapparent_encodingzResponse.apparent_encodings(  >$,// ; ;7rCr FcZfd}jr(tjtrt 5tt s t dtdtj}|}jr|n|}|rt|}|S)aIterates over the response data. When stream=True is set on the request, this avoids reading the content at once into memory for large responses. The chunk size is the number of bytes it should read into memory. This is not necessarily the length of each item returned as decoding can take place. chunk_size must be of type int or None. A value of None will function differently depending on the value of `stream`. stream=True will read data as it arrives in whatever size the chunks are received. If stream=False, data is returned as a single chunk. If decode_unicode is True, content will be decoded using the best available encoding based on the response. c3Ktjdr jdEd{Vn#t$r}t |d}~wt $r}t |d}~wt$r}t|d}~wt$r}t|d}~wwxYw j }|sn|V"d_ dS)NstreamT)decode_content) rLrr'rrrr rrrRequestsSSLErrorrEr)rchunk chunk_sizer?s rAgeneratez'Response.iter_content..generate0s'tx**  .#xz$OOOOOOOOOO$222.q111"222.q111'---)!,,,...*1---.  HMM*55E KKK  &*D " " "s9"= B/A B/#A22 B/?B B/B**B/Nz+chunk_size must be an int, it is instead a r) rrIrboolr%intrtyper-r0)r?r+decode_unicoder, reused_chunks stream_chunkschunkss`` rArzResponse.iter_contents" * * * * * *.  ! j&E&E %'' '  #Jz3,G,G #Qd:>N>NQQQ $DM:>>   "&"8Km  B3FDAAF rCNc#>Kd}|||D]x}|||z}|r||}n|}|r7|dr/|r-|dd|dkr|}nd}|Ed{Vy||VdSdS)zIterates over the response data, one line at a time. When stream=True is set on the request, this avoids reading the content at once into memory for large responses. .. note:: This method is not reentrant safe. N)r+r0)rsplit splitlinespop)r?r+r0 delimiterpendingr*liness rA iter_lineszResponse.iter_linesYs&&!.'    E"% + I..((** r u r2%)1K1K))++          MMMMM  rCc|jdurd|jrtd|jdks|jd|_n4d|tpd|_d|_|jS)z"Content of the response, in bytes.Fz2The content for this response was already consumedrNrCT)rr RuntimeErrorrrr>rCONTENT_CHUNK_SIZErs rArzResponse.contentzs =E ! !% Y"#WXXX1$$(8 $ #):):;M)N)N O O VSV !%}rCcd}|j}|jsdS|j|j} t|j|d}n-#tt f$rt|jd}YnwxYw|S)aContent of the response, in unicode. If Response.encoding is None, encoding will be guessed using ``charset_normalizer`` or ``chardet``. The encoding of the response content is determined based solely on HTTP headers, following RFC 2616 to the letter. If you can take advantage of non-HTTP knowledge to make a better guess at the encoding, you should set ``r.encoding`` appropriately before accessing this property. Nr9replace)errors)rrr$rJ LookupErrorr)r?rrs rAtextz Response.texts=| 2 = -H :$,CCCGGY' : : :$,y999GGG :s:'A$#A$c |js|jrt|jdkr~t|j}|h t j|j|fi|S#t$rYn1t$r%}t|j |j |j d}~wwxYw t j|j fi|S#t$r%}t|j |j |j d}~wwxYw)zReturns the json-encoded content of a response, if any. :param \*\*kwargs: Optional arguments that ``json.loads`` takes. :raises requests.exceptions.JSONDecodeError: If the response body does not contain valid json. rVN)rrr_r,rloadsr\UnicodeDecodeErrorrRequestsJSONDecodeErrormsgdocposrD)r?kwargsrrs rArz Response.jsons } G G#dl2C2Ca2G2G &dl33H# G&,T\-@-@-J-JUUfUUU) D&GGG1!%FFFG ?$TY99&99 9 ? ? ?*!%>> > ?s5)A(( B"4 B"= BB"&B== C, C''C,c|jd}i}|rCt|}|D]1}|dp|d}|||<2|S)z8Returns the parsed header links of the response, if any.linkrelr:)rYrr.)r?rresolved_linkslinksrNkeys rArQzResponse.linksss!!&))  +&v..E + +hhuoo8%&*s##rCcd}t|jtrF |jd}n1#t$r|jd}Yn wxYw|j}d|jcxkrdkrnn|jd|d|j}n)d|jcxkrdkrnn|jd |d|j}|rt|| d S) z+Raises :class:`HTTPError`, if one occurred.r9rGz iso-8859-1iiz Client Error: z for url: iXz Server Error: )responseN)rIrrKr\rGrr:r!)r?http_error_msgrs rArzResponse.raise_for_statuss1 dk5 ) ) !  :++G44% : : :++L99 :[F $" ( ( ( (S ( ( ( ( (#PPFPPdhPP ND$ * * * *s * * * * *#PPFPPdhPP   ;NT::: : ; ;s9$A A c|js|jt|jdd}| |dSdS)zReleases the connection back to the pool. Once this method has been called the underlying ``raw`` object must not be accessed again. *Note: Should not normally need to be called explicitly.* release_connN)rrrr)r?rWs rArzResponse.closesQ %  HNN   tx>>  # LNNNNN $ #rC)r F)rorprqrrrrrrr rrrrFrrrrrr!r$rITER_CHUNK_SIZEr<rrDrrQrrrtrCrArrs   I---^LLL###222&&&  X QQXQ   X XX8888v)$BX$##X#J???BX ;;;:     rCr)Rrrencodings.idna encodingsiorpip._vendor.urllib3.exceptionsrrrrrpip._vendor.urllib3.fieldsr pip._vendor.urllib3.filepostr pip._vendor.urllib3.utilr _internal_utilsr rrrcompatrrrrrrrrrrrrrrrr exceptionsrrr r!r"r#rHr$r)r%r~r& status_codesr' structuresr(utilsr)r*r+r,r-r.r/r0r1r2movedfoundothertemporary_redirectrrDEFAULT_REDIRECT_LIMITr?rXr5rvrrrrtrCrArks  ######433333BBBBBB......????????('''''3333333333MMMMMMMMMMCBBBBB%%%%%%444444++++++ ++++++                          K K K   w"w"w"w"w"w"w"w"t0PPPPPPPPfD4D4D4D4D4*,=D4D4D4N MMMMMMMMMMrC