
    ,hw                        d Z ddlZddl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 ddlmZ dd	l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mZ ddl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.m/Z/m0Z0m1Z1m2Z2m3Z3 ejh                  dk(  rejj                  Z6nej                  Z6efdZ7efdZ8 G d d      Z9 G d de9      Z:d Z;y)z
requests.sessions
~~~~~~~~~~~~~~~~~

This module provides a Session object to manage and persist settings across
requests (cookies, auth, proxies).
    N)OrderedDict)	timedelta   )to_native_string)HTTPAdapter)_basic_auth_str)Mapping	cookieliburljoinurlparse)RequestsCookieJarcookiejar_from_dictextract_cookies_to_jarmerge_cookies)ChunkedEncodingErrorContentDecodingErrorInvalidSchemaTooManyRedirects)default_hooksdispatch_hook)DEFAULT_REDIRECT_LIMITREDIRECT_STATIPreparedRequestRequest)codes)CaseInsensitiveDict)
DEFAULT_PORTSdefault_headersget_auth_from_urlget_environ_proxiesget_netrc_authrequote_uriresolve_proxiesrewind_bodyshould_bypass_proxiesto_key_val_listwin32c                    || S | |S t        |t              rt        | t              s| S  |t        |            }|j                  t        |              |j	                         D cg c]
  \  }}|	| }}}|D ]  }||=  |S c c}}w )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`
    )
isinstancer	   r&   updateitems)request_settingsession_setting
dict_classmerged_settingkv	none_keyskeys           S/var/www/html/Resume-Scraper/venv/lib/python3.12/site-packages/requests/sessions.pymerge_settingr5   =   s      	?G,OW1U @AN//:; "0!5!5!7Ev119EIE  3  	 Fs   )
B4Bc                 |    ||j                  d      g k(  r| S | | j                  d      g k(  r|S t        | ||      S )zProperly merges both requests and session hooks.

    This is necessary because when request_hooks == {'response': []}, the
    merge breaks Session hooks entirely.
    response)getr5   )request_hookssession_hooksr.   s      r4   merge_hooksr;   [   sO      1 1* = C 1 1* = CzBB    c                   >    e Zd Zd Zd Z	 	 	 	 	 	 ddZd Zd Zd Zy)	SessionRedirectMixinc                 t    |j                   r,|j                  d   }|j                  d      }t        |d      S y)z7Receives a Response. Returns a redirect URI or ``None``locationlatin1utf8N)is_redirectheadersencoder   )selfrespr@   s      r4   get_redirect_targetz(SessionRedirectMixin.get_redirect_targetk   s;     ||J/H  x0H#Hf55r<   c                    t        |      }t        |      }|j                  |j                  k7  ry|j                  dk(  r,|j                  dv r|j                  dk(  r|j                  dv ry|j                  |j                  k7  }|j                  |j                  k7  }t	        j
                  |j                  d      df}|s|j                  |v r|j                  |v ry|xs |S )zFDecide whether Authorization header should be removed when redirectingThttp)P   Nhttps)i  NFN)r   hostnameschemeportr   r8   )rF   old_urlnew_url
old_parsed
new_parsedchanged_portchanged_schemedefault_ports           r4   should_strip_authz&SessionRedirectMixin.should_strip_auth   s    g&
g&
*"5"55 ':-!!W,;. "*//9#**j.?.??%))**;*;TBDI</</ -~-r<   Nc	           
   +     K   g }
| j                  |      }t        |j                        j                  }|r|j	                         }|
j                  |       |
dd |_        	 |j                   t        |j                        | j                  k\  rt        d| j                   d|      |j!                          |j#                  d      r;t        |j                        }d	j%                  t'        |j(                        |g      }t        |      }|j                  d
k(  r|r|j+                  |      }n|j                  r|j                  }|j-                         }|j.                  s t1        |j                  t3        |            }nt3        |      }t'        |      |_        | j5                  ||       |j6                  t8        j:                  t8        j<                  fvr,d}|D ]  }|j>                  jA                  |d         d|_!        |j>                  }|jA                  dd       tE        |jF                  ||j                         tI        |jF                  | jJ                         |jM                  |jF                         | jO                  ||      }| jQ                  ||       |jR                  duxr
 d|v xs d|v }|rtU        |       |}|r| nP | jV                  |f|||||dd|	}tE        | jJ                  ||j                         | j                  |      }| |ryy# t        t        t        f$ r  |j                  j                  d       Y w xY ww)zBReceives a Response. Returns a generator of Responses or Requests.r   NF)decode_contentz	Exceeded z redirects.)r7   z//: )fragment)Content-LengthzContent-TypeTransfer-EncodingCookier]   r^   )streamtimeoutverifycertproxiesallow_redirects),rH   r   urlr\   copyappendhistorycontentr   r   RuntimeErrorrawreadlenmax_redirectsr   close
startswithjoinr   rN   _replacegeturlnetlocr   r"   rebuild_methodstatus_coder   temporary_redirectpermanent_redirectrD   popbodyr   _cookiesr   cookiesprepare_cookiesrebuild_proxiesrebuild_auth_body_positionr$   send)rF   rG   reqr`   ra   rb   rc   rd   yield_requestsadapter_kwargshistrf   previous_fragmentprepared_requestparsed_rurlparsedpurged_headersheaderrD   
rewindables                       r4   resolve_redirectsz&SessionRedirectMixin.resolve_redirects   s2     &&t,$SWW-66"xxz KK8DL4 4<< D$6$66& 2 23;?$ 
 JJL ~~d#&txx0hh 01C1C DcJK c]F"$):2CD$*OO!--/C
 ==dhhC(89!#&#3C#8  0$7 ((((( 
 "Y, ?F$,,00>?(, %&..GKK$'
 ##3#<#<c488L*33T\\B,,-=-F-FG **+;WEG.5
 *88D  G+M/Bg/M 
 ,- #C	 tyy	!#!#$)	 %	 't||5EtxxP ..t4
O  )*>M 4U34s1   A!M,$L5 0KM,3M,50M)%M,(M))M,c                     |j                   }|j                  }d|v r)| j                  |j                  j                  |      r|d= | j                  rt        |      nd}||j                  |       yy)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)rD   rf   rW   request	trust_envr!   prepare_auth)rF   r   r7   rD   rf   new_auths         r4   r   z!SessionRedirectMixin.rebuild_auth  sw    
 #**""g%$*@*@  #+

 ( +/..>#&d))(3  r<   c                 ,   |j                   }t        |j                        j                  }t	        ||| j
                        }d|v r|d= 	 t        ||         \  }}|j                  d      s|r|rt        ||      |d<   |S # t        $ r d\  }}Y 6w xY w)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.

        :rtype: dict
        zProxy-AuthorizationNNrL   )
rD   r   rf   rN   r#   r   r   KeyErrorrq   r   )rF   r   rd   rD   rN   new_proxiesusernamepasswords           r4   r   z$SessionRedirectMixin.rebuild_proxies.  s     #***../66%&6P G+-.	,!2;v3F!GHh   )h8-<Xx-PG)*  	,!+Hh	,s   B BBc                    |j                   }|j                  t        j                  k(  r|dk7  rd}|j                  t        j                  k(  r|dk7  rd}|j                  t        j
                  k(  r|dk(  rd}||_         y)zWhen being redirected we may want to change the method of the request
        based on certain specs or browser behavior.
        HEADGETPOSTN)methodrw   r   	see_otherfoundmoved)rF   r   r7   r   s       r4   rv   z#SessionRedirectMixin.rebuild_methodM  sx     "(( 5??2v7GF 5;;.6V3CF 5;;.6V3CF"(r<   )FNTNNF)	__name__
__module____qualname__rH   rW   r   r   r   rv    r<   r4   r>   r>   j   s7    (.H yv4(>)r<   r>   c                       e Zd ZdZg dZd Zd Zd Zd Z	 	 	 	 	 	 	 	 	 	 	 	 	 	 ddZ	d	 Z
d
 Zd ZddZddZddZd Zd Zd Zd Zd Zd Zd Zd Zy)Sessiona  A 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]>
    )rD   r}   authrd   hooksparamsrb   rc   adaptersr`   r   ro   c                 ^   t               | _        d | _        i | _        t	               | _        i | _        d| _        d| _        d | _	        t        | _        d| _        t        i       | _        t               | _        | j#                  dt%                      | j#                  dt%                      y )NFTzhttps://zhttp://)r   rD   r   rd   r   r   r   r`   rb   rc   r   ro   r   r   r}   r   r   mountr   rF   s    r4   __init__zSession.__init__  s     '( 	
  #_

    	 4  +2. $

:{}-

9km,r<   c                     | S Nr   r   s    r4   	__enter__zSession.__enter__  s    r<   c                 $    | j                          y r   )rp   )rF   argss     r4   __exit__zSession.__exit__  s    

r<   c                    |j                   xs i }t        |t        j                        st	        |      }t        t        t               | j                         |      }|j                  }| j                  r#|s!| j                  st        |j                        }t               }|j                  |j                  j                         |j                  |j                  |j                   |j"                  t%        |j&                  | j&                  t(              t%        |j*                  | j*                        t%        || j                        |t-        |j.                  | j.                        
       |S )a  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.
        :rtype: requests.PreparedRequest
        )r.   )
r   rf   filesdatajsonrD   r   r   r}   r   )r}   r)   r
   	CookieJarr   r   r   r   r   r!   rf   r   preparer   upperr   r   r   r5   rD   r   r   r;   r   )rF   r   r}   merged_cookiesr   ps         r4   prepare_requestzSession.prepare_request  s    //'R '9#6#67)'2G '+-t||<g

 ||>>$tyy!'++.D			>>'')--!:M !=tTYY/"gmmTZZ8 	 	
 r<   Nc                    t        |j                         ||||xs i ||xs i |||
      }| j                  |      }|xs i }| j                  |j                  ||||      }|	|
d}|j                  |        | j                  |fi |}|S )a	  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 hooks: (optional) Dictionary mapping hook name to one event or
            list of events, event must be callable.
        :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
        )
r   rf   rD   r   r   r   r   r   r}   r   )ra   re   )r   r   r   merge_environment_settingsrf   r*   r   )rF   r   rf   r   r   rD   r}   r   r   ra   re   rd   r   r`   rb   rc   r   r   prepsettingssend_kwargsrG   s                         r4   r   zSession.request  s    ~ <<><R
 ##C(-R22HHgvvt
 .
 	8$tyy--r<   c                 N    |j                  dd        | j                  d|fi |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
        re   Tr   
setdefaultr   rF   rf   kwargss      r4   r8   zSession.getQ  s-     	+T2t||E31&11r<   c                 N    |j                  dd        | j                  d|fi |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
        re   TOPTIONSr   r   s      r4   optionszSession.options\  s-     	+T2t||Is5f55r<   c                 N    |j                  dd        | j                  d|fi |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
        re   Fr   r   r   s      r4   headzSession.headg  s-     	+U3t||FC2622r<   c                 0     | j                   d|f||d|S )a  Sends 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   )r   r   r   )rF   rf   r   r   r   s        r4   postzSession.postr  s#     t||FCHdHHHr<   c                 .     | j                   d|fd|i|S )au  Sends 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
        PUTr   r   rF   rf   r   r   s       r4   putzSession.put  s!     t||E3<T<V<<r<   c                 .     | j                   d|fd|i|S )aw  Sends 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
        PATCHr   r   r   s       r4   patchzSession.patch  s!     t||GS>t>v>>r<   c                 *     | j                   d|fi |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
        DELETEr   r   s      r4   deletezSession.delete  s     t||Hc4V44r<   c                 f   |j                  d| j                         |j                  d| j                         |j                  d| j                         d|vr$t	        || j
                  | j                        |d<   t        |t              rt        d      |j                  dd      }|j                  d      }|j                  }| j                  |j                        }t               } |j                   |fi |}t               |z
  }	t#        |		      |_        t'        d
||fi |}|j(                  r<|j(                  D ]-  }
t+        | j,                  |
j.                  |
j0                         / t+        | j,                  ||j0                         |r$ | j2                  ||fi |}|D 
cg c]  }
|
 }}
ng }|r)|j5                  d|       |j                         }||_        |s%	 t7         | j2                  ||fddi|      |_        |s|j<                   |S c c}
w # t:        $ r Y  w xY w)zISend a given PreparedRequest.

        :rtype: requests.Response
        r`   rb   rc   rd   z#You can only send PreparedRequests.re   T)rf   )secondsr7   r   r   )r   r`   rb   rc   r#   rd   r   r)   r   
ValueErrorrz   r8   r   get_adapterrf   preferred_clockr   r   elapsedr   ri   r   r}   r   rl   r   insertnext_nextStopIterationrj   )rF   r   r   re   r`   r   adapterstartrr   rG   genri   s                r4   r   zSession.send  s    	(DKK0(DKK0&$)),F" /t~~ VF9 gw'BCC !**%6=H% ""w{{"3  ! GLL+F+ "#e+g.	 *eQ9&9 99		 M&t||T\\488LM 	t||Waee< ($((G>v>C(+,t,G,G NN1a AAI *D**1gUdUfU II1 -$ ! s   /	H+$H$ $	H0/H0c                    | j                   r||j                  d      nd}t        ||      }|j                         D ]  \  }}	|j	                  ||	        |du s|Dt
        j                  j                  d      xs# t
        j                  j                  d      xs |}t        || j                        }t        || j                        }t        || j                        }t        || j                        }||||dS )z^
        Check the environment and merge it with some settings.

        :rtype: dict
        Nno_proxy)r   TREQUESTS_CA_BUNDLECURL_CA_BUNDLE)rd   r`   rb   rc   )r   r8   r    r+   r   osenvironr5   rd   r`   rb   rc   )
rF   rf   rd   r`   rb   rc   r   env_proxiesr0   r1   s
             r4   r   z"Session.merge_environment_settings  s     >>292Ew{{:.4H-cHEK#))+ )1""1a()
 ~JJNN#78 zz~~&67   6vt{{3vt{{3T499-"fPTUUr<   c                     | j                   j                         D ]6  \  }}|j                         j                  |j                               s4|c S  t	        d|      )z~
        Returns the appropriate connection adapter for the given URL.

        :rtype: requests.adapters.BaseAdapter
        z&No connection adapters were found for )r   r+   lowerrq   r   )rF   rf   prefixr   s       r4   r   zSession.get_adapter  sX      $}}224 	OFGyy{%%flln5	
 DSGLMMr<   c                 b    | j                   j                         D ]  }|j                           y)z+Closes all adapters and as such the sessionN)r   valuesrp   )rF   r1   s     r4   rp   zSession.close  s'    %%' 	AGGI	r<   c                     || j                   |<   | j                   D cg c]  }t        |      t        |      k  s| }}|D ]*  }| j                   j                  |      | j                   |<   , yc c}w )zwRegisters a connection adapter to a prefix.

        Adapters are sorted in descending order by prefix length.
        N)r   rn   rz   )rF   r   r   r0   keys_to_mover3   s         r4   r   zSession.mount  sj    
 !(f#'==IaCFS[4HII 	8C!%!2!23!7DMM#	8 Js
   A1A1c           	      Z    | j                   D ci c]  }|t        | |d        }}|S c c}w r   )	__attrs__getattr)rF   attrstates      r4   __getstate__zSession.__getstate__*  s2    =A^^LTwtT400LL Ms   (c                 N    |j                         D ]  \  }}t        | ||        y r   )r+   setattr)rF   r   r   values       r4   __setstate__zSession.__setstate__.  s'     ;;= 	'KD%D$&	'r<   )NNNNNNNTNNNNNNr   r   )r   r   r   __doc__r   r   r   r   r   r   r8   r   r   r   r   r   r   r   r   r   rp   r   r   r  r   r<   r4   r   r   d  s    $I;-z)^ #[z	2	6	3I
=
?5KZV>N
	8'r<   r   c                      t               S )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
    )r   r   r<   r4   sessionr  3  s     9r<   )<r  r   systimecollectionsr   datetimer   _internal_utilsr   r   r   r   r   compatr	   r
   r   r   r}   r   r   r   r   
exceptionsr   r   r   r   r   r   r   modelsr   r   r   r   status_codesr   
structuresr   utilsr   r   r   r    r!   r"   r#   r$   r%   r&   platformperf_counterr   r5   r;   r>   r   r  r   r<   r4   <module>r     s    
 
  #  - ! ! 9 9   0    +   <<7''OiiO @K < :E Cw) w)tL'" L'^r<   