7,jm$dZddlmZddlZddlZddlZddlZddlmZddl m Z m Z m Z m Z mZmZmZmZddl mZddl mZddl mZdd l mZdd lmZmZdd lmZdd lm Z dd l!m"Z"ddl#m$Z$ddl%m&Z&m'Z'ddl(m)Z)ddl*m+Z+m,Z,mZm-Z-m.Z.m/Z/mZm0Z0m1Z1mZddl2m3Z3ddl4m5Z5ddl6m7Z7m8Z8m9Z9m:Z:m;Z;mZ>n#e?$rd2dZ>YnwxYwej@rddlAmBZBddlmZCddlDmEZFdd l2mGZGdd!lEmHZId"ZJd#ZKdZLdZMd3d-ZNGd.d/ZOGd0d1eOZPdS)4z requests.adapters ~~~~~~~~~~~~~~~~~ This module contains the transport adapters that Requests uses to define and maintain connections. ) annotationsN)Any)ClosedPoolErrorConnectTimeoutErrorLocationValueError MaxRetryErrorNewConnectionError ProtocolErrorReadTimeoutError ResponseError) HTTPError) InvalidHeader) ProxyError)SSLError) PoolManagerproxy_from_url)Timeout) parse_url)Retry)_basic_auth_str) basestringurlparse)extract_cookies_to_jar) ConnectionErrorConnectTimeoutrInvalidProxyURL InvalidSchema InvalidURLr ReadTimeout RetryErrorr)Response)CaseInsensitiveDict)DEFAULT_CA_BUNDLE_PATHget_auth_from_urlget_encoding_from_headersprepend_scheme_if_needed select_proxy urldefragauth)SOCKSProxyManagerargsrkwargsreturnNonec td)Nz'Missing dependencies for SOCKS support.)r)r+r,s AC:\PYTHON\GemmaClient\venv\Lib\site-packages\requests/adapters.pyr*r*BsEFFF)HTTPConnectionPool)r)_types)PreparedRequest) is_preparedF requestr4verifybool | str | None client_certtuple[str, str] | str | None poolmanagerr%tuple[dict[str, Any], dict[str, Any]]ci}i}t|j}|j}|j}d} |durd} n?t |t r*tj |s||d<n||d<| |d<|Dt |tr*t|dkr|d|d <|d |d <n||d <||j |d }||fS) N CERT_REQUIREDF CERT_NONEca_certs ca_cert_dir cert_reqsr cert_filerkey_file)schemehostport) rurlrGlowerrI isinstancestrospathisdirtuplelenhostname) r7r8r:r< host_params pool_kwargsparsed_request_urlrGrIrCs r0_urllib3_request_contextrWUs #%K"$K!'+..  & , , . .F  "DI  FC 0w}}V$$ 0&,K # #)/K &(K  k5 ) ) 3c+.>.>!.C.C'21~K $&1!nK # #(3K $"+K  ##r1c@eZdZdZdfd Z dddZddZxZS) BaseAdapterzThe Base Transport Adapterr-r.cHtdSN)super__init__)self __class__s r0r]zBaseAdapter.__init__}s r1FNTr7r4streambooltimeout_t.TimeoutTyper8 _t.VerifyTypecert _t.CertTypeproxiesdict[str, str] | Noner"ct)aCSends PreparedRequest object. Returns Response object. :param request: The :class:`PreparedRequest ` being sent. :param stream: (optional) Whether to stream the request content. :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) ` tuple. :type timeout: float or tuple :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 :param cert: (optional) Any user-provided SSL certificate to be trusted. :param proxies: (optional) The proxies dictionary to apply to the request. NotImplementedError)r^r7r`rbr8rergs r0sendzBaseAdapter.sends ."!r1ct)z!Cleans up adapter specific items.rjr^s r0closezBaseAdapter.closes!!r1r-r.FNTNNr7r4r`rarbrcr8rdrerfrgrhr-r")__name__ __module__ __qualname____doc__r]rlro __classcell__r_s@r0rYrYzs$$ "& $ )-"""""2""""""""r1rYceZdZUdZgdZded<ded<ded<ded <d ed <d ed <d ed<ded<eeeefdFfd Z dGdZ dHdZ efdId Z dJd$Z dKd+ZdLd0Z dMdNd4Z dOdPd8Z dMdQd9ZdRd:ZdSd;ZdTd=ZdUd?Z dVdWdEZxZS)X HTTPAdapteraThe built-in HTTP Adapter for urllib3. Provides a general-case interface for Requests sessions to contact HTTP and HTTPS urls by implementing the Transport Adapter interface. This class will usually be created by the :class:`Session ` class under the covers. :param pool_connections: The number of urllib3 connection pools to cache. :param pool_maxsize: The maximum number of connections to save in the pool. :param max_retries: The maximum number of retries each connection should attempt. Note, this applies only to failed DNS lookups, socket connections and connection timeouts, never to requests where data has made it to the server. By default, Requests does not retry failed connections. If you need granular control over the conditions under which we retry a request, import urllib3's ``Retry`` class and pass that instead. :param pool_block: Whether the connection pool should block for connections. Usage:: >>> import requests >>> s = requests.Session() >>> a = requests.adapters.HTTPAdapter(max_retries=3) >>> s.mount('http://', a) ) max_retriesconfig_pool_connections _pool_maxsize _pool_blockz list[str] __attrs__rr{dict[str, Any]r| proxy_managerintr}r~rar _PoolManagerr<pool_connections pool_maxsize int | Retry pool_blockr-r.c4|tkrtdd|_ntj||_i|_i|_t ||_||_ ||_ | |||dS)NrF)readblock) DEFAULT_RETRIESrr{from_intr|rr\r]r}r~rinit_poolmanager)r^rrr{rr_s r0r]zHTTPAdapter.__init__s / ) )$QU333D  $~k::D   !1)% . JOOOOOr1c*fdjDS)Nc4i|]}|t|dSr[)getattr).0attrr^s r0 z,HTTPAdapter.__getstate__..s'KKKDgdD$//KKKr1)rrns`r0 __getstate__zHTTPAdapter.__getstate__sKKKKDNKKKKr1stateci|_i|_|D]\}}t|||||j|j|jdS)Nr)rr|itemssetattrrr}r~r)r^rrvalues r0 __setstate__zHTTPAdapter.__setstate__sz   ;;== ' 'KD% D$ & & & &   "D$6d>N      r1 connectionsmaxsizerrUrc Z||_||_||_td|||d||_dS)aInitializes a urllib3 PoolManager. This method should not be called from user code, and is only exposed for use when subclassing the :class:`HTTPAdapter `. :param connections: The number of urllib3 connection pools to cache. :param maxsize: The maximum number of connections to save in the pool. :param block: Block when no free connections are available. :param pool_kwargs: Extra keyword arguments used to initialize the Pool Manager. ) num_poolsrrN)r}r~rrr<)r^rrrrUs r0rzHTTPAdapter.init_poolmanagersQ&"-$ & !     r1proxyrM proxy_kwargsc ||jvr|j|}n|dr?t|\}}t |f|||j|j|jd|x}|j|<n@||}t|f||j|j|jd|x}|j|<|S)aReturn urllib3 ProxyManager for the given proxy. This method should not be called from user code, and is only exposed for use when subclassing the :class:`HTTPAdapter `. :param proxy: The proxy to return a urllib3 ProxyManager for. :param proxy_kwargs: Extra keyword arguments used to configure the Proxy Manager. :returns: ProxyManager :rtype: urllib3.ProxyManager socks)usernamepasswordrrr) proxy_headersrrr) rrK startswithr%r*r}r~rrr)r^rrmanagerrrrs r0proxy_manager_forzHTTPAdapter.proxy_manager_for s D& & &(/GG [[]] % %g . . !25!9!9 Hh2C3!!0*& 3333 Gd(//!..u55M2@3+0*& 33  33 Gd(/r1connrJr8rdrerfc|dr||rzd}|dur|}|st}|rtj|st d|d|_tj|s||_ n||_ nd|_d|_ d|_ |rt|ts|d|_ |d|_n||_ d|_|j r;tj|j st d |j |jr=tj|jst d |jdSdSdS) aAVerify a SSL certificate. This method should not be called from user code, and is only exposed for use when subclassing the :class:`HTTPAdapter `. :param conn: The urllib3 connection object associated with the cert. :param url: The requested URL. :param verify: 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 :param cert: The SSL certificate to verify. httpsNTzCCould not find a suitable TLS CA certificate bundle, invalid path: r?r@rrz7Could not find the TLS certificate file, invalid path: z/Could not find the TLS key file, invalid path: )rKrr$rNrOexistsOSErrorrCrPrArBrLrrErF)r^rrJr8recert_locs r0 cert_verifyzHTTPAdapter.cert_verify3s 99;; ! !' * * $v $HT!!! 21 27>>(#;#; 0%-00 -DN7==** , ( #+  (DN DM#D   dJ// %!%a $Q !% $ ~ bgnnT^&D&D 6%)^66} RW^^DM%B%B UdmUU      r1reqr4respr"ct|sJt}t|dd|_t t|di|_t |j|_||_|jj |_ t|j tr |j d|_ n |j |_ t|j||||_||_|S)aBuilds a :class:`Response ` object from a urllib3 response. This should not be called from user code, and is only exposed for use when subclassing the :class:`HTTPAdapter ` :param req: The :class:`PreparedRequest ` used to generate the response. :param resp: The urllib3 response object. :rtype: requests.Response statusNheaderszutf-8) _is_preparedr"r status_coder#rr&encodingrawreasonrLrJbytesdecodercookiesr7 connection)r^rrresponses r0build_responsezHTTPAdapter.build_responsemsC     :: 'tXt<</wtY/K/KLL6h6FGG ",- cgu % % #7>>'22HLL7HL x/d;;;"r1Nr7r=c0t||||jS)a Build the PoolKey attributes used by urllib3 to return a connection. This looks at the PreparedRequest, the user-specified verify value, and the value of the cert parameter to determine what PoolKey values to use to select a connection from a given urllib3 Connection Pool. The SSL related pool key arguments are not consistently set. As of this writing, use the following to determine what keys may be in that dictionary: * If ``verify`` is ``True``, ``"ssl_context"`` will be set and will be the default Requests SSL Context * If ``verify`` is ``False``, ``"ssl_context"`` will not be set but ``"cert_reqs"`` will be set * If ``verify`` is a string, (i.e., it is a user-specified trust bundle) ``"ca_certs"`` will be set if the string is not a directory recognized by :py:func:`os.path.isdir`, otherwise ``"ca_cert_dir"`` will be set. * If ``"cert"`` is specified, ``"cert_file"`` will always be set. If ``"cert"`` is a tuple with a second item, ``"key_file"`` will also be present To override these settings, one may subclass this class, call this method and use the above logic to change parameters as desired. For example, if one wishes to use a custom :py:class:`ssl.SSLContext` one must both set ``"ssl_context"`` and based on what else they require, alter the other keys to ensure the desired behaviour. :param request: The PreparedRequest being sent over the connection. :type request: :class:`~requests.models.PreparedRequest` :param verify: 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. :param cert: (optional) Any user-provided SSL certificate for client authentication (a.k.a., mTLS). This may be a string (i.e., just the path to a file which holds both certificate and key) or a tuple of length 2 with the certificate file path and key file path. :returns: A tuple of two dictionaries. The first is the "host parameters" portion of the Pool Key including scheme, hostname, and port. The second is a dictionary of SSLContext related parameters. )rWr<)r^r7r8res r0$build_connection_pool_key_attributesz0HTTPAdapter.build_connection_pool_key_attributessd(t?OPPPr1rgrhr2ct|sJt|j|} ||||\}}n##t$r}t ||d}~wwxYw|r\t |d}t|} | jstd| |} | j di|d|i} n|j j di|d|i} | S)auReturns a urllib3 connection for the given request and TLS settings. This should not be called from user code, and is only exposed for use when subclassing the :class:`HTTPAdapter `. :param request: The :class:`PreparedRequest ` object to be sent over the connection. :param verify: 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. :param proxies: (optional) The proxies dictionary to apply to the request. :param cert: (optional) Any user-provided SSL certificate to be used for client authentication (a.k.a., mTLS). :rtype: urllib3.HTTPConnectionPool r7NhttpFPlease check proxy URL. It is malformed and could be missing the host.rUr) rr(rJr ValueErrorrr'rrHrrconnection_from_hostr<) r^r7r8rgrerrTrUe proxy_urlrrs r0get_connection_with_tls_contextz+HTTPAdapter.get_connection_with_tls_contextsU4G$$$$$W['22 1'+'P'P(( $K  1 1 1Q000 0 1  ,UF;;E!%((I> %5!22599M5=5+6DD 94#8+6D sA A# AA#ctjdtt||}|r`t |d}t |}|jstd||}| |}n=t|}| }|j |}|S)aDEPRECATED: Users should move to `get_connection_with_tls_context` for all subclasses of HTTPAdapter using Requests>=2.32.2. Returns a urllib3 connection for the given URL. This should not be called from user code, and is only exposed for use when subclassing the :class:`HTTPAdapter `. :param url: The URL to connect to. :param proxies: (optional) A Requests-style dictionary of proxies used on this request. :rtype: urllib3.HTTPConnectionPool z`get_connection` has been deprecated in favor of `get_connection_with_tls_context`. Custom HTTPAdapter subclasses will need to migrate for Requests>=2.32.2. Please see https://github.com/psf/requests/pull/6710 for more details.rr) warningswarnDeprecationWarningr(r'rrHrrconnection_from_urlrgeturlr<)r^rJrgrrrrparseds r0get_connectionzHTTPAdapter.get_connections  N    S'**  =,UF;;E!%((I> %5!22599M 44S99DDc]]F--//C#77<`. :param request: The :class:`PreparedRequest ` being sent. :param proxies: A dictionary of schemes or schemes and hosts to proxy URLs. :rtype: str rFr) rr(rJrrGrKrpath_urlr)) r^r7rgrrGis_proxied_http_requestusing_socks_proxy proxy_schemerJs r0 request_urlzHTTPAdapter.request_url5s G$$$$$W['22'+&&-"'"=Fg,=!  A#E??17799L , 7 7 @ @  " -+< - ,,C r1r,c dS)a"Add any headers needed by the connection. As of v2.0 this does nothing by default, but is left for overriding by users that subclass the :class:`HTTPAdapter `. This should not be called from user code, and is only exposed for use when subclassing the :class:`HTTPAdapter `. :param request: The :class:`PreparedRequest ` to add headers to. :param kwargs: The keyword arguments from the call to send(). Nr)r^r7r,s r0 add_headerszHTTPAdapter.add_headersWs  r1dict[str, str]cXi}t|\}}|rt|||d<|S)aReturns a dictionary of the headers to add to any request sent through a proxy. This works with urllib3 magic to ensure that they are correctly sent to the proxy, rather than in a tunnelled request if CONNECT is being used. This should not be called from user code, and is only exposed for use when subclassing the :class:`HTTPAdapter `. :param proxy: The url of the proxy being used for this request. :rtype: dict zProxy-Authorization)r%r)r^rrrrs r0rzHTTPAdapter.proxy_headerses>#%.u55(  Q-$r}t'||d}~wt6$r}t9|d}~wt:t@f$rx}t|t:rt=||t|tBrtE||t|tFrtI||d}~wwxYw|%||S) aSends PreparedRequest object. Returns Response object. :param request: The :class:`PreparedRequest ` being sent. :param stream: (optional) Whether to stream the request content. :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) ` tuple. :type timeout: float or tuple or urllib3 Timeout object :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 :param cert: (optional) Any user-provided SSL certificate to be trusted. :param proxies: (optional) The proxies dictionary to apply to the request. :rtype: requests.Response )rgrerN)r`rbr8rergzContent-Length)connectrzInvalid timeout za. Pass a (connect, read) timeout tuple, or a single float to set both timeouts to the same value.F) methodrJbodyrredirectassert_same_hostpreload_contentdecode_contentretriesrbchunked)&rrrrrrJrrrrrLrQ TimeoutSaucerurlopenrr{r rrrrrr rr r! _ProxyErrorr _SSLErrorrr _HTTPErrorr r _InvalidHeaderrr)r^r7r`rbr8rergrrrJrrrresolved_timeoutrerrs r0rlzHTTPAdapter.sendzs2G$$$$$ 177t8DD" 1 1 1Q000 0 1 w{FD999w00      |t+R/?7?/RS gu % % K  ' #/d#K#K#K      QwQQQ   . . K&  +G'JJJ 3 <<~\!& %$((  DDw' 8 8 8!#w777 7 6 6 6!($788 =!!(,>??=(G<<<<!(M22 5 G4444!(K00 5 G4444!(I.. 3q'2222!!W555 5 6 6 6!!W555 5   Q-- :&   !Y'' q'2222A/00 !!W5555A~.. #Aw7777 ""7D111sj- A AA CC<)4EL+0F L+CI%% L+2J L+JL+3A3L&&L+) rrrrr{rrrar-r.)r-r)rrr-r.) rrrrrrarUrr-r.)rrMrrr-r) rrrJrMr8rdrerfr-r.)rr4rrr-r"r[)r7r4r8rdrerfr-r=)NN) r7r4r8rdrgrhrerfr-r2)rJrMrgrhr-r2rp)r7r4rgrhr-rM)r7r4r,rr-r.)rrMr-rrqrr)rsrtrurvr__annotations__DEFAULT_POOLSIZErDEFAULT_POOLBLOCKr]rrrrrrrrrrorrrrlrwrxs@r0rzrzsR4I!!!!!1,#2, PPPPPPP,LLLL     "(      <$$$$L8888t$$$$NTX2Q2Q2Q2Q2Qp*. 77777t:>)))))V    D     0"& $ )-r2r2r2r2r2r2r2r2r2r1rz)r+rr,rr-r.) r7r4r8r9r:r;r<rr-r=)Qrv __future__ros.pathrNsockettypingrrurllib3.exceptionsrrrrr r r r r rrrrrrrurllib3.poolmanagerrr urllib3.utilrrrurllib3.util.retryrauthrcompatrrrr exceptionsrrrrrr r!modelsr" structuresr#utilsr$r%r&r'r(r)urllib3.contrib.socksr* ImportError TYPE_CHECKINGurllib3.connectionpoolr2rr3_tr4r5rrrrDEFAULT_POOL_TIMEOUTrWrYrzrr1r0r s#"""""                     766666>>>>>>888888444444;;;;;;;;000000""""""$$$$$$!!!!!!((((((((++++++                        ++++++G7777777GGGGGGGGGG  (999999??????''''''//////"$"$"$"$J!"!"!"!"!"!"!"!"HN 2N 2N 2N 2N 2+N 2N 2N 2N 2N 2s.B55 CC