kf+4dZddlZddlZddlZddlmZddlmZddl m Z ddl m Z m Z mZmZddlmZdd lmZdd lmZdd lmZdd lmZmZmZdd lmZmZmZm Z m!Z!m"Z"m#Z#m$Z$ddl%m&Z&m'Z'ddl(m)Z)m*Z*m+Z+m,Z,m-Z-m.Z.m/Z/m0Z0m1Z1m2Z2ddl3m4Z4m5Z5m6Z6m7Z7m8Z8m9Z9m:Z:m;Z;mZ>m?Z?ddl3m@ZAddlBmCZCeCjDeCjEeCjFeCjGeCjHfZIdZJdZKdZLGddeMZNGddeMZOGddeOZPGddeNeOZQGddeMZRdS) z` requests.models ~~~~~~~~~~~~~~~ This module contains the primary objects that power Requests. N) RequestField)encode_multipart_formdata) parse_url) DecodeErrorReadTimeoutError ProtocolErrorLocationParseError)UnsupportedOperation) default_hooks)CaseInsensitiveDict) HTTPBasicAuth)cookiejar_from_dictget_cookie_header_copy_cookie_jar) HTTPError MissingSchema InvalidURLChunkedEncodingErrorContentDecodingErrorConnectionErrorStreamConsumedErrorInvalidJSONError)to_native_stringunicode_is_ascii) guess_filenameget_auth_from_url requote_uristream_decode_response_unicodeto_key_val_listparse_header_links iter_slicesguess_json_utf super_lencheck_header_validity) CallableMapping cookielib urlunparseurlsplit urlencodestrbytesis_py2chardet builtin_str basestring)json)codesi(icPeZdZedZedZedZdS)RequestEncodingMixincg}t|j}|j}|sd}|||j}|r*|d||d|S)zBuild the path URL to use./?)r*urlpathappendqueryjoin)selfr;pr<r>s o/builddir/build/BUILD/imunify360-venv-2.3.5/opt/imunify360/venv/lib/python3.11/site-packages/requests/models.pypath_urlzRequestEncodingMixin.path_url=s~ 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) isinstancer,r-hasattrr r1r=encoder+)dataresultkvsvs rB_encode_paramsz#RequestEncodingMixin._encode_paramsRs0 dS%L ) ) K T6 " " K T: & & F(.. N N2b*--WR5L5LBNNA} 2z2RequestHooksMixin.register_hook..s1$P$P1 1h8O8O$PQ$P$P$P$P$P$PrDN)hooksrZrJr&r=rKextendr@eventhooks rB register_hookzRequestHooksMixin.register_hooks  " "PTYZ[[ [ dH % % Q Ju  $ $T * * * * * T: & & Q Ju  $ $$P$P$P$P$P P P P P P Q QrDcj |j||dS#t$rYdSwxYw)ziDeregister a previously registered hook. Returns True if the hook existed, False if not. TF)r|removerZr~s rBderegister_hookz!RequestHooksMixin.deregister_hooksI   Ju  $ $T * * *4   55 s $ 22N)rnrorprrrsrDrBrurus5 Q Q Q     rDruc*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;rXrarMr2paramsauthcookies) r@rr;rXrarMrrrr|r2rOrQs rB__init__zRequest.__init__s \rrtm""W~6m"__ 5;;==)) 0 0FQ   QQ  / / / /        rDcd|jzS)Nzrr@s rB__repr__zRequest.__repr__s4;//rDc t}||j|j|j|j|j|j|j|j |j |j  |S)zXConstructs a :class:`PreparedRequest ` for transmission and returns it.) rr;rXrarMr2rrrr|) PreparedRequestpreparerr;rXrarMr2rrrr|r@rAs rBrzRequest.preparesa    ;L*;L*  rD NNNNNNNNNN)rnrorp__doc__rrrrsrDrBrrsZ8CGCG2000rDrczeZdZdZdZ 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|_dSrx)rr;rX_cookiesrlr r|_body_positionrs rBrzPreparedRequest.__init__%s@    "__ "rDNc 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;rXrarMrrrr|r2s rBrzPreparedRequest.prepare6s F### f%%% W%%% W%%% $t,,, $$$$ 5!!!!!rDcd|jzS)Nzrrs rBrzPreparedRequest.__repr__Hs'4;77rDct}|j|_|j|_|j|jnd|_t |j|_|j|_|j|_|j |_ |Srx) rrr;rXcopyrrrlr|rrs rBrzPreparedRequest.copyKss   ;+/<+CDL%%''' %dm44 *.rDc|||_|j-t|j|_dSdS)zPrepares the given HTTP method.N)rrupper)r@rs rBrzPreparedRequest.prepare_methodVs: ; "*4;+<+<+>+>??DKKK # "rDcddl} ||dd}n#|j$rtwxYw|S)NrT)uts46rH)idnarLr[ IDNAError UnicodeError)hostrs rB_get_idna_encoded_hostz&PreparedRequest._get_idna_encoded_host\s]  ;;t4;0077@@DD~      s *1Ac t|tr|d}n%trt |nt |}|}d|vr0|ds ||_ dS t|\}}}}}}} n #t$r} t| j d} ~ wwxYw|s4d} | t|d} t!| |std|zt#|s4 ||}nA#t&$rtdwxYw|drtd|pd } | r| d z } | |z } |r| dt |zz } |sd }trt|t r|d }t| t r| d } t|t r|d }t|t r|d }t| t r| d } t|t tfrt|}||} | r |r|d | }n| }t-t/|| |d|| g}||_ dS)zPrepares the given HTTP URL.utf8:httpNzDInvalid URL {0!r}: No schema supplied. Perhaps you meant http://{0}?z Invalid URL %r: No host suppliedzURL has an invalid label.*r:@r8rH&)rJr-r[r.unicoder,lstriplower startswithr;rr rargsformatrrrrrrLrRrr))r@r;rschemerrportr<r>fragmenteerrornetloc enc_paramss rBrzPreparedRequest.prepare_urlfs0 c5 ! ! 7**V$$CC"(6'#,,,c#hhCjjll #::ciikk44V<<:DH F &>Gnn ;FD$dE88! & & &af% % & '[ELL!1#v!>!>??E&& & G?#EFF F  %% : >22488 > > > !<=== > __T " " :899 9   cMF$  & cCIIo %F D  4&#&& 0w//&#&& 0w//$$$ ,{{7++%%% . W--(C(( 4#??733 fsEl + + .%f--F((00  # ##(55**5"*ffdD%%RSSTTs$B22 C<C  C,EEct|_|rB|D]/}t||\}}||jt |<.dSdS)z Prepares the given HTTP headers.N)r rXrr%r)r@rXheaderrVvalues rBrzPreparedRequest.prepare_headersss+,,  =!--// = =%f---$ e7< -d3344  = = = =rDc  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#|ddE ||_n*#t(t*f$rt-|_YnwxYw|rt/d |rt1||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)requestrHrGtellz1Streamed bodies and files are mutually exclusive.Content-LengthchunkedzTransfer-EncodingrFz!application/x-www-form-urlencodedz content-typez Content-Type) complexjsondumpsrZrrJr-rLallrKr1r]r\r'r$ TypeErrorAttributeErrorr getattrrrIOErrorOSErrorobjectNotImplementedErrorr0rXrmrRprepare_content_lengthrl) r@rMrar2rlrYve is_streamlengths rBrzPreparedRequest.prepare_bodys{  ,(.L 7 &tu===dd 7 7 7$R6666 7dE** ,{{7++ D* % %4*dE7!CDD D   * < "4~/CD    DtVT**63*.))++D'')333+1((D'''3  _)*]^^^ >1A9C C%$C%<D$D=<D=c|,t|}|rt||jd<dSdS|jdvr&|jdd|jd<dSdSdS)z>Prepare Content-Length header based on request method and bodyNr)GETHEAD0)r$r0rXrget)r@rlrs rBrz&PreparedRequest.prepare_content_lengths  t__F E2=V1D1D -... E E[ / /DL4D4DEU4V4V4^.1DL) * * *0 /4^4^rDr:cJ|'t|j}t|r|nd}|rwt|trt |dkr t |}||}|j|j| |j dSdS)z"Prepares the given HTTP auth data.NrT) rr;anyrJr\r^r__dict__updaterrl)r@rr;url_authrs rBrzPreparedRequest.prepare_auths <(22H"8}}688$D  3$&& ,3t99>>$d+T A M  , , ,  ' ' 2 2 2 2 2 3 3rDct|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)rJr( CookieJarrrrrX)r@r cookie_headers rBrzPreparedRequest.prepare_cookies4sb gy2 3 3 9#DMM/88DM)$->>  $%2DL " " " % $rDcP|pg}|D]}||||dS)zPrepares the given hooks.N)r)r@r|rs rBrzPreparedRequest.prepare_hooksHsC   4 4E   ueEl 3 3 3 3 4 4rDrrx)r:)rnrorprrrrrrrrrrrrrrrrrsrDrBrrs(###$CGCG""""$888   @@@ \TTTl = = =HHHHT 1 1 13333,333(44444rDrc(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_coderXr;historyencodingreasonrelapsedrcd|_d|_d|_d|_t |_d|_d|_d|_g|_ d|_ ti|_ tjd|_d|_dS)NFr)r_content_consumed_nextrr rXrawr;rrrrrdatetime timedeltarrrs rBrzResponse.__init__\s !&   +,,    +2..  )!,,  rDc|Srxrsrs rB __enter__zResponse.__enter__s rDc.|dSrx)close)r@rs rB__exit__zResponse.__exit__s rDcFjsjfdjDS)Nc4i|]}|t|dSrx)r)ryattrr@s rB z)Response.__getstate__..s'KKKDgdD$//KKKrD)rcontent __attrs__rs`rB __getstate__zResponse.__getstate__s3%  LLKKKKDNKKKKrDc|D]\}}t|||t|ddt|dddS)NrTr)rsetattr)r@staterVrs rB __setstate__zResponse.__setstate__s_ ;;== ' 'KD% D$ & & & & )4000eT"""""rDcd|jzS)Nz)rrs rBrzResponse.__repr__s D$455rDc|jSakReturns True if :attr:`status_code` is less than 400. This attribute checks if the status code of the response is between 400 and 600 to see if there was a client error or a server error. If the status code, is between 200 and 400, this will return True. This is **not** a check to see if the response code is ``200 OK``. okrs rB__bool__zResponse.__bool__ wrDc|jSr r rs rB __nonzero__zResponse.__nonzero__rrDc,|dS)z,Allows you to use a response as an iterator.) iter_contentrs rBrGzResponse.__iter__s  %%%rDcT |n#t$rYdSwxYwdS)axReturns True if :attr:`status_code` is less than 400, False if not. This attribute checks if the status code of the response is between 400 and 600 to see if there was a client error or a server error. If the status code is between 200 and 400, this will return True. This is **not** a check to see if the response code is ``200 OK``. FT)raise_for_statusrrs rBr z Response.oksC   ! ! # # # #   55 ts  %%c0d|jvo |jtvS)zTrue if this Response is a well-formed HTTP redirect that could have been processed automatically (by :meth:`Session.resolve_redirects`). location)rXrREDIRECT_STATIrs rB is_redirectzResponse.is_redirects dl*Qt/?>/QRrDcRd|jvo|jtjtjfvS)z@True if this Response one of the permanent versions of redirect.r)rXrr3moved_permanentlypermanent_redirectrs rBis_permanent_redirectzResponse.is_permanent_redirects*dl*vt/?ED[]b]uCv/vwrDc|jS)zTReturns a PreparedRequest for the next request in a redirect chain, if there is one.)rrs rBnextz Response.nexts zrDc@tj|jdS)zOThe apparent encoding, provided by the charset_normalizer or chardet libraries.r)r/detectrrs rBapparent_encodingzResponse.apparent_encodings~dl++J77rDr FcXfd}jr(tjtrt 4tt st dtztj}|}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~ jdD]}|Vn|#t$r}t |d}~wt $r}t |d}~wt$r}t|d}~wwxYw j }|sn|V"d_ dS)NstreamT)decode_content) rKrr&rrrrrrrFr)chunkr chunk_sizer@s rBgeneratez'Response.iter_content..generatestx** -!%D!Q!Q$$# $$222.q111"222.q111'---)!,,,-  HMM*55E KKK  &*D " " "s-#> BA B$A33 BBBNz.chunk_size must be an int, it is instead a %s.) rrJrboolrintrtyper"r)r@r)decode_unicoder* reused_chunks stream_chunkschunkss`` rBrzResponse.iter_contents" * * * * * *,  ! aj&E&E a%'' '  #Jz3,G,G #LtT^O_O__`` `#DM:>>   "&"8Km  B3FDAAF rDNc#@Kd}|||D]y}|||z}|r||}n|}|r7|dr/|r-|dd|dkr|}nd}|D]}|Vz||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)r.)rsplit splitlinespop)r@r)r. delimiterpendingr(lineslines rB iter_lineszResponse.iter_liness&&*^&\\  E"% + I..((** r u r2%)1K1K))++      MMMMM  rDc|jdurd|jrtd|jdks|jd|_n4d|tpd|_d|_|jS)z"Content of the response, in bytes.Fz2The content for this response was already consumedrNrDT)rr RuntimeErrorrrr?rCONTENT_CHUNK_SIZErs rBrzResponse.content7s =E ! !% J"HJJJ1$$(8 $ #):):;M)N)N O O VSV !%}rDcd}|j}|jstdS|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. Nr:replace)errors)rrr,r# LookupErrorr)r@rrs rBtextz Response.textKs=| r77N = -H :$,CCCGGY' : : :$,y999GGG :sA'A10A1c |jsp|jrit|jdkrQt|j}|; t j|j|fi|S#t$rYnwxYwt j|jfi|S)a.Returns the json-encoded content of a response, if any. :param \*\*kwargs: Optional arguments that ``json.loads`` takes. :raises simplejson.JSONDecodeError: If the response body does not contain valid json and simplejson is installed. :raises json.JSONDecodeError: If the response body does not contain valid json and simplejson is not installed on Python 3. :raises ValueError: If the response body does not contain valid json and simplejson is not installed on Python 2. rU) rrr^r#rloadsr[UnicodeDecodeErrorrC)r@kwargsrs rBr2z Response.jsonqs}  #dl2C2Ca2G2G &dl33H# &, ++H559?* D   55f555s)A(( A54A5c|jd}i}|rCt|}|D]1}|dp|d}|||<2|S)z8Returns the parsed header links of the response, if any.linkrelr;)rXrr!)r@rllinksrIkeys rBrLzResponse.linkssr!!&))   &v..E  hhuoo8%#rDcd}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.r:rHz iso-8859-1iiz Client Error: z for url: iXz Server Error: )responseN)rJrr-r[rFrr;r)r@http_error_msgrs rBrzResponse.raise_for_statuss- dk5 ) ) !  :++G44% : : :++L99 :[F $" ( ( ( (S ( ( ( ( (CGCSCSCSU[U[U[]a]e]efNN D$ * * * *s * * * * *CGCSCSCSU[U[U[]a]e]efN  ;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@rRs rBrzResponse.closesQ %  HNN   tx>>  # LNNNNN $ #rD)r F)rnrorprrrrrrrrrrrGrqr rrr r#rITER_CHUNK_SIZEr;rrCr2rLrrrsrDrBrrRsI ---^LLL###666&&&  X SSXS xxXxX88X85555n%4EUY>X&##X#J666>X";;;2     rDr)Srrsysencodings.idna encodingsurllib3.fieldsrurllib3.filepostr urllib3.utilrurllib3.exceptionsrrrr ior r|r structuresr rrrrrr exceptionsrrrrrrrr_internal_utilsrrutilsrrrrr r!r"r#r$r%compatr&r'r(r)r*r+r,r-r.r/r0r1r2r status_codesr3movedfoundothertemporary_redirectrrDEFAULT_REDIRECT_LIMITr>rSrr6rurrrrsrDrBrgs) ''''''666666""""""FFFFFFFFFFFF$##### ++++++MMMMMMMMMMRRRRRRRRRRRRRRRRRRRR@???????CCCCCCCCCCCCCCCCCCCCCCCC............................('''''  K K K   o"o"o"o"o"6o"o"o"d0GGGGGGGGT44444*,=444D tttttvtttttrD