<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0-alpha1/dist/css/bootstrap.min.css" rel="stylesheet"
        integrity="sha384-GLhlTQ8iRABdZLl6O3oVMWSktQOp6b7In1Zl3/Jr59b6EGGoI1aFkw7cmDA6j6gD" crossorigin="anonymous">
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.3.0/css/all.min.css"
        integrity="sha512-SzlrxWUlpfuzQ+pcUCosxcglQRNAq/DZjVsC0lE40xsADsfeQoEypE+enwcOiGjk/bSuGGKHEyjSoQ1zVisanQ=="
        crossorigin="anonymous" referrerpolicy="no-referrer" />
</head>
</html>

ReW                 @   s  d  Z  d d l Z d d l m Z d d l m Z d d l m Z d d l m Z m	 Z	 m
 Z
 m Z m Z d d l m Z m Z m Z m Z d d	 l m Z m Z m Z d d
 l m Z m Z d d l m Z m Z m Z d d l m Z m Z m  Z  m! Z! d d l" m# Z# d d l$ m% Z% d d l m& Z& m' Z' m( Z( m) Z) m* Z* d d l+ m, Z, d d l m- Z- e	 d d  Z. e	 d d  Z/ Gd d   d e0  Z1 Gd d   d e1  Z2 d d   Z3 d S)z
requests.session
~~~~~~~~~~~~~~~~

This module provides a Session object to manage and persist settings across
requests (cookies, auth, proxies).

    N)Mapping)datetime   )_basic_auth_str)	cookielibOrderedDicturljoinurlparsebuiltin_str)cookiejar_from_dictextract_cookies_to_jarRequestsCookieJarmerge_cookies)RequestPreparedRequestDEFAULT_REDIRECT_LIMIT)default_hooksdispatch_hook)to_key_val_listdefault_headersto_native_string)TooManyRedirectsInvalidSchemaChunkedEncodingErrorContentDecodingError)CaseInsensitiveDict)HTTPAdapter)requote_uriget_environ_proxiesget_netrc_authshould_bypass_proxiesget_auth_from_url)codes)REDIRECT_STATIc             C   s   | d k r |  S|  d k r  | St  | t  o; t  |  t  sB |  S| t |   } | j t |    x0 |  j   D]" \ } } | d k rt | | =qt qt Wt d d   | j   D  } | S)z
    Determines 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`
    Nc             s   s-   |  ]# \ } } | d  k	 r | | f Vq d  S)N ).0kvr$   r$   8/tmp/pip-ztkk0jow-build/pip/_vendor/requests/sessions.py	<genexpr>C   s    z merge_setting.<locals>.<genexpr>)
isinstancer   r   updateitemsdict)request_settingsession_setting
dict_classmerged_settingr&   r'   r$   r$   r(   merge_setting'   s    r2   c             C   sZ   | d k s! | j  d  g  k r% |  S|  d k sF |  j  d  g  k rJ | St |  | |  S)z
    Properly merges both requests and session hooks.

    This is necessary because when request_hooks == {'response': []}, the
    merge breaks Session hooks entirely.
    Nresponse)getr2   )request_hookssession_hooksr0   r$   r$   r(   merge_hooksH   s
    !!r7   c               @   sC   e  Z d  Z d d d d d d d  Z d d   Z d d	   Z d S)
SessionRedirectMixinFNTc             c   s  d } x| j  r| j   }	 y | j Wn. t t t f k
 rY | j j d d  Yn X| |  j k r t	 d |  j   n  | j
   | j d }
 | j } |
 j d  r t | j  } d | j |
 f }
 n  t |
  } | j   }
 t |
  j st | j t |
   }
 n t |
  }
 t |
  |	 _ | j t j k rW| d k rWd	 } n  | j t j k r~| d k r~d	 } n  | j t j k r| d
 k rd	 } n  | |	 _ | j t j t j f k rd |	 j k r|	 j d =n  d |	 _ n  |	 j } y | d =Wn t k
 rYn Xt |	 j  |	 | j  |	 j  j! |  j"  |	 j# |	 j   |  j$ |	 |  } |  j% |	 |  |	 } |  j& | d | d | d | d | d | d d } t |  j" |	 | j  | d 7} | Vq	 Wd S)z6Receives a Response. Returns a generator of Responses.r   decode_contentFzExceeded %s redirects.locationz//z%s:%sHEADGETPOSTzContent-LengthNCookiestreamtimeoutverifycertproxiesallow_redirectsr   )'is_redirectcopycontentr   r   RuntimeErrorrawreadmax_redirectsr   closeheadersmethod
startswithr	   urlschemegeturlnetlocr   r   r   status_coder"   	see_otherfoundmoved	temporaryresumebodyKeyErrorr   _cookiesr+   cookiesprepare_cookiesrebuild_proxiesrebuild_authsend)selfrespreqr?   r@   rA   rB   rC   iprepared_requestrP   rN   parsed_rurlparsedrM   r$   r$   r(   resolve_redirectsY   sn    
							
z&SessionRedirectMixin.resolve_redirectsc             C   s   | j  } | j } d | k r[ t | j j  } t |  } | j | j k r[ | d =q[ n  |  j rp t |  n d } | d k	 r | j |  n  d S)z
        When 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)rM   rP   r	   requesthostname	trust_envr   prepare_auth)rb   rf   r3   rM   rP   original_parsedredirect_parsednew_authr$   r$   r(   r`      s    		z!SessionRedirectMixin.rebuild_authc             C   s  | j  } | j } t |  j } | d k	 r9 | j   n i  } |  j r t |  r t |  } | j |  } | r | j	 | | |  q n  d | k r | d =n  y t
 | |  \ }	 }
 Wn t k
 r d \ }	 }
 Yn X|	 r|
 rt |	 |
  | d <n  | S)a  
        This 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.
        NzProxy-Authorization)NN)rM   rP   r	   rQ   rF   rm   r    r   r4   
setdefaultr!   r[   r   )rb   rf   rC   rM   rP   rQ   new_proxiesenviron_proxiesproxyusernamepasswordr$   r$   r(   r_      s$    		
z$SessionRedirectMixin.rebuild_proxies)__name__
__module____qualname__ri   r`   r_   r$   r$   r$   r(   r8   X   s   ar8   c               @   sN  e  Z d  Z d Z d d d d d d d d	 d
 d d d d d g Z d d   Z d d   Z d d   Z d d   Z d d d d d d d d d d d d d d d  Z	 d d   Z
 d d   Z d  d!   Z d d" d#  Z d d$ d%  Z d d& d'  Z d( d)   Z d* d+   Z d, d-   Z d. d/   Z d0 d1   Z d2 d3   Z d4 d5   Z d S)6SessionzA Requests session.

    Provides cookie persistence, connection-pooling, and configuration.

    Basic Usage::

      >>> import requests
      >>> s = requests.Session()
      >>> s.get('http://httpbin.org/get')
      200
    rM   r]   authr@   rC   hooksparamsrA   rB   prefetchadaptersr?   rm   rK   c             C   s   t    |  _ d  |  _ i  |  _ t   |  _ i  |  _ d |  _ d |  _ d  |  _	 t
 |  _ d |  _ t i   |  _ t   |  _ |  j d t    |  j d t    d  S)NFTzhttps://zhttp://)r   rM   r|   rC   r   r}   r~   r?   rA   rB   r   rK   rm   r   r]   r   r   mountr   )rb   r$   r$   r(   __init__  s    								zSession.__init__c             C   s   |  S)Nr$   )rb   r$   r$   r(   	__enter__?  s    zSession.__enter__c             G   s   |  j    d  S)N)rL   )rb   argsr$   r$   r(   __exit__B  s    zSession.__exit__c             C   s!  | j  p i  } t | t j  s0 t |  } n  t t t   |  j   |  } | j } |  j r | r |  j r t	 | j
  } n  t   } | j d | j j   d | j
 d | j d | j d t | j |  j d t d t | j |  j  d t | |  j  d	 | d
 t | j |  j   	| S)ab  Constructs 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.
        rN   rP   filesdatarM   r0   r~   r|   r]   r}   )r]   r*   r   	CookieJarr   r   r   r|   rm   r   rP   r   preparerN   upperr   r   r2   rM   r   r~   r7   r}   )rb   rk   r]   merged_cookiesr|   pr$   r$   r(   prepare_requestE  s(    							zSession.prepare_requestNTc             C   s  t  |  } t d | j   d | d | d | d | p9 i  d | pE i  d | d | d	 |  	} |  j |  } | pu i  } |  j rt |  p i  } x* | j   D] \ } } | j | |  q W| r | d
 k	 r t j	 j
 d  } n  | r| d
 k	 rt j	 j
 d  } qn  t | |  j  } t | |  j  } t | |  j  } t | |  j  } i | d 6|	 d 6| d 6| d 6| d 6|
 d 6} |  j | |  } | S)a4  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 or bytes 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) Float describing the timeout of the
            request in seconds.
        :param allow_redirects: (optional) Boolean. Set to True by default.
        :param proxies: (optional) Dictionary mapping protocol to the URL of
            the proxy.
        :param stream: (optional) whether to immediately download the response
            content. Defaults to ``False``.
        :param verify: (optional) if ``True``, the SSL cert will be verified.
            A CA_BUNDLE path can also be provided.
        :param cert: (optional) if String, path to ssl client cert file (.pem).
            If Tuple, ('cert', 'key') pair.
        rN   rP   rM   r   r   r~   r|   r]   r}   FREQUESTS_CA_BUNDLECURL_CA_BUNDLEr?   r@   rA   rB   rC   rD   )r
   r   r   r   rm   r   r,   rr   osenvironr4   r2   rC   r?   rA   rB   ra   )rb   rN   rP   r~   r   rM   r]   r   r|   r@   rD   rC   r}   r?   rA   rB   rd   prepenv_proxiesr&   r'   send_kwargsrc   r$   r$   r(   rk   l  sD    ,		
zSession.requestc             K   s#   | j  d d  |  j d | |  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.
        rD   Tr<   )rr   rk   )rb   rP   kwargsr$   r$   r(   r4     s    zSession.getc             K   s#   | j  d d  |  j d | |  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.
        rD   TOPTIONS)rr   rk   )rb   rP   r   r$   r$   r(   options  s    zSession.optionsc             K   s#   | j  d d  |  j d | |  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.
        rD   Fr;   )rr   rk   )rb   rP   r   r$   r$   r(   head  s    zSession.headc             K   s   |  j  d | d | | S)a8  Sends a POST request. Returns :class:`Response` object.

        :param url: URL for the new :class:`Request` object.
        :param data: (optional) Dictionary, bytes, or file-like object to send in the body of the :class:`Request`.
        :param \*\*kwargs: Optional arguments that ``request`` takes.
        r=   r   )rk   )rb   rP   r   r   r$   r$   r(   post  s    zSession.postc             K   s   |  j  d | d | | S)a7  Sends a PUT request. Returns :class:`Response` object.

        :param url: URL for the new :class:`Request` object.
        :param data: (optional) Dictionary, bytes, or file-like object to send in the body of the :class:`Request`.
        :param \*\*kwargs: Optional arguments that ``request`` takes.
        PUTr   )rk   )rb   rP   r   r   r$   r$   r(   put  s    zSession.putc             K   s   |  j  d | d | | S)a9  Sends a PATCH request. Returns :class:`Response` object.

        :param url: URL for the new :class:`Request` object.
        :param data: (optional) Dictionary, bytes, or file-like object to send in the body of the :class:`Request`.
        :param \*\*kwargs: Optional arguments that ``request`` takes.
        PATCHr   )rk   )rb   rP   r   r   r$   r$   r(   patch  s    zSession.patchc             K   s   |  j  d | |  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.
        DELETE)rk   )rb   rP   r   r$   r$   r(   delete  s    zSession.deletec             K   s  | j  d |  j  | j  d |  j  | j  d |  j  | j  d |  j  t | t  sj t d   n  | j d d  } | j	 d  } | j	 d  } | j	 d  } | j	 d  } | j	 d  } | j
 }	 |  j d	 | j  }
 t j   } |
 j | |  } t j   | | _ t d
 |	 | |  } | j rdx- | j D] } t |  j | j | j  q>Wn  t |  j | | j  |  j | | d | d | d | d | d | } | rd d   | D n g  } | r| j d |  | j   } | | _ n  | s| j n  | S)zSend a given PreparedRequest.r?   rA   rB   rC   z#You can only send PreparedRequests.rD   Tr@   rP   r3   c             S   s   g  |  ] } |  q Sr$   r$   )r%   rc   r$   r$   r(   
<listcomp>I  s   	 z Session.send.<locals>.<listcomp>r   )rr   r?   rA   rB   rC   r*   r   
ValueErrorpopr4   r}   get_adapterrP   r   utcnowra   elapsedr   historyr   r]   rk   rI   ri   insertrG   )rb   rk   r   rD   r?   r@   rA   rB   rC   r}   adapterstartrrc   genr   r$   r$   r(   ra     sH    		 	
zSession.sendc             C   sM   x6 |  j  j   D]% \ } } | j   j |  r | Sq Wt d |   d S)z>Returns the appropriate connnection adapter for the given URL.z*No connection adapters were found for '%s'N)r   r,   lowerrO   r   )rb   rP   prefixr   r$   r$   r(   r   X  s    zSession.get_adapterc             C   s(   x! |  j  j   D] } | j   q Wd S)z+Closes all adapters and as such the sessionN)r   valuesrL   )rb   r'   r$   r$   r(   rL   b  s    zSession.closec                sW   | |  j    <  f d d   |  j  D } x' | D] } |  j  j |  |  j  | <q0 Wd S)zkRegisters a connection adapter to a prefix.

        Adapters are sorted in descending order by key length.c                s.   g  |  ]$ } t  |  t     k  r |  q Sr$   )len)r%   r&   )r   r$   r(   r   m  s   	 z!Session.mount.<locals>.<listcomp>N)r   r   )rb   r   r   keys_to_movekeyr$   )r   r(   r   g  s    zSession.mountc                s    t    f d d     j D  S)Nc             3   s'   |  ] } | t    | d   f Vq d  S)N)getattr)r%   attr)rb   r$   r(   r)   s  s    z'Session.__getstate__.<locals>.<genexpr>)r-   	__attrs__)rb   r$   )rb   r(   __getstate__r  s    zSession.__getstate__c             C   s1   x* | j    D] \ } } t |  | |  q Wd  S)N)r,   setattr)rb   stater   valuer$   r$   r(   __setstate__u  s    zSession.__setstate__)rx   ry   rz   __doc__r   r   r   r   r   rk   r4   r   r   r   r   r   r   ra   r   rL   r   r   r   r$   r$   r$   r(   r{      sD   3(S





	G
r{   c               C   s   t    S)z2Returns a :class:`Session` for context-management.)r{   r$   r$   r$   r(   sessionz  s    r   )4r   r   collectionsr   r   r|   r   compatr   r   r   r	   r
   r]   r   r   r   r   modelsr   r   r   r}   r   r   utilsr   r   r   
exceptionsr   r   r   r   
structuresr   r   r   r   r   r   r    r!   status_codesr"   r#   r2   r7   objectr8   r{   r   r$   r$   r$   r(   <module>
   s*   (""(! 