adapters.pyc
1 o 2 ��Yc'S � @ s� d Z ddlZddlZddlmZmZ ddlmZ ddlm Z 3 ddlmZmZm Z mZ ddlmZ ddlmZmZ dd lmZ dd 4 lmZmZ ddlmZ ddlmZ dd lmZ ddlmZ ddl m!Z! ddl"m#Z#m$Z$ ddl%m&Z& ddl'm(Z(m)Z)m Z m*Z*m+Z+m,Z,mZm-Z-m.Z.mZ ddl/m0Z0 ddl1m2Z2 ddl3m4Z4m5Z5m6Z6m7Z7m8Z8m9Z9m:Z: zddl;m<Z< W n e=y� dd� Z<Y nw dZ>dZ?dZ@dZAG dd� d�ZBG dd� deB�ZCdS ) z� 5 requests.adapters 6 ~~~~~~~~~~~~~~~~~ 7 8 This module contains the transport adapters that Requests uses to define 9 and maintain connections. 10 � N)�ClosedPoolError�ConnectTimeoutError)� HTTPError)� InvalidHeader)�LocationValueError� MaxRetryError�NewConnectionError� ProtocolError)� 11 ProxyError)�ReadTimeoutError� ResponseError)�SSLError)�PoolManager�proxy_from_url)�HTTPResponse)�Timeout)� parse_url)�Retry� )�_basic_auth_str)� 12 basestring�urlparse)�extract_cookies_to_jar) 13 �ConnectionError�ConnectTimeoutr �InvalidProxyURL� InvalidSchema� 14 InvalidURLr 15 �ReadTimeout� 16 RetryErrorr )�Response)�CaseInsensitiveDict)�DEFAULT_CA_BUNDLE_PATH�extract_zipped_paths�get_auth_from_url�get_encoding_from_headers�prepend_scheme_if_needed�select_proxy� urldefragauth)�SOCKSProxyManagerc O s t d��)Nz'Missing dependencies for SOCKS support.)r )�args�kwargs� r, ��C:\Users\Jacks.GUTTSPC\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\requests\adapters.pyr) = s r) F� 17 c s4 e Zd ZdZ� fdd�Z ddd�Zd d 18 � Z� ZS )�BaseAdapterzThe Base Transport Adapterc s t � �� d S �N)�super�__init__��self�� __class__r, r- r2 J s zBaseAdapter.__init__FNTc C � t �)aC Sends PreparedRequest object. Returns Response object. 19 20 :param request: The :class:`PreparedRequest <PreparedRequest>` being sent. 21 :param stream: (optional) Whether to stream the request content. 22 :param timeout: (optional) How long to wait for the server to send 23 data before giving up, as a float, or a :ref:`(connect timeout, 24 read timeout) <timeouts>` tuple. 25 :type timeout: float or tuple 26 :param verify: (optional) Either a boolean, in which case it controls whether we verify 27 the server's TLS certificate, or a string, in which case it must be a path 28 to a CA bundle to use 29 :param cert: (optional) Any user-provided SSL certificate to be trusted. 30 :param proxies: (optional) The proxies dictionary to apply to the request. 31 ��NotImplementedError)r4 �request�stream�timeout�verify�cert�proxiesr, r, r- �sendM s zBaseAdapter.sendc C r7 )z!Cleans up adapter specific items.r8 r3 r, r, r- �close` s zBaseAdapter.close�FNTNN)�__name__� 32 __module__�__qualname__�__doc__r2 r@ rA � __classcell__r, r, r5 r- r/ G s 33 �r/ c s� e Zd ZdZg d�Zeeeef� fdd� Zdd� Z dd� Z 34 efd d 35 �Zdd� Zd d� Z dd� Zd dd�Zdd� Zdd� Zdd� Zdd� Z d!dd�Z� ZS )"�HTTPAdaptera� The built-in HTTP Adapter for urllib3. 36 37 Provides a general-case interface for Requests sessions to contact HTTP and 38 HTTPS urls by implementing the Transport Adapter interface. This class will 39 usually be created by the :class:`Session <Session>` class under the 40 covers. 41 42 :param pool_connections: The number of urllib3 connection pools to cache. 43 :param pool_maxsize: The maximum number of connections to save in the pool. 44 :param max_retries: The maximum number of retries each connection 45 should attempt. Note, this applies only to failed DNS lookups, socket 46 connections and connection timeouts, never to requests where data has 47 made it to the server. By default, Requests does not retry failed 48 connections. If you need granular control over the conditions under 49 which we retry a request, import urllib3's ``Retry`` class and pass 50 that instead. 51 :param pool_block: Whether the connection pool should block for connections. 52 53 Usage:: 54 55 >>> import requests 56 >>> s = requests.Session() 57 >>> a = requests.adapters.HTTPAdapter(max_retries=3) 58 >>> s.mount('http://', a) 59 )�max_retries�config�_pool_connections� _pool_maxsize�_pool_blockc s` |t krtddd�| _nt�|�| _i | _i | _t� �� || _|| _ || _ 60 | j|||d� d S )Nr F)�read��block)�DEFAULT_RETRIESr rI �from_intrJ � proxy_managerr1 r2 rK rL rM �init_poolmanager)r4 Zpool_connectionsZpool_maxsizerI Z 61 pool_blockr5 r, r- r2 � s 62 zHTTPAdapter.__init__c s � fdd�� j D �S )Nc s i | ] }|t � |d ��qS r0 )�getattr)�.0�attrr3 r, r- � 63 <dictcomp>� s z,HTTPAdapter.__getstate__.<locals>.<dictcomp>)� __attrs__r3 r, r3 r- �__getstate__� s zHTTPAdapter.__getstate__c C sD i | _ i | _|�� D ] 64 \}}t| ||� q 65 | j| j| j| jd� d S )NrO )rS rJ �items�setattrrT rK rL rM )r4 �staterW �valuer, r, r- �__setstate__� s 66 �zHTTPAdapter.__setstate__c K s0 || _ || _|| _td|||dd�|��| _dS )a Initializes a urllib3 PoolManager. 67 68 This method should not be called from user code, and is only 69 exposed for use when subclassing the 70 :class:`HTTPAdapter <requests.adapters.HTTPAdapter>`. 71 72 :param connections: The number of urllib3 connection pools to cache. 73 :param maxsize: The maximum number of connections to save in the pool. 74 :param block: Block when no free connections are available. 75 :param pool_kwargs: Extra keyword arguments used to initialize the Pool Manager. 76 T)� num_pools�maxsizerP �strictNr, )rK rL rM r �poolmanager)r4 �connectionsra rP �pool_kwargsr, r, r- rT � s ��zHTTPAdapter.init_poolmanagerc K s� || j v r| j | }|S |�� �d�r1t|�\}}t|f||| j| j| jd�|�� }| j |<