AlkantarClanX12
Current Path : /opt/alt/python38/lib/python3.8/site-packages/urllib3/contrib/__pycache__/ |
Current File : //opt/alt/python38/lib/python3.8/site-packages/urllib3/contrib/__pycache__/appengine.cpython-38.pyc |
U ��`+ � @ s d Z ddlmZ ddlZddlZddlZddlmZmZm Z m Z mZmZ ddl mZ ddlmZ ddlmZ dd lmZ dd lmZ ddlmZ zdd lmZ W n ek r� dZY nX e�e�ZG dd� de�ZG dd� de�Z G dd� de�Z!ej"Z"ej#Z#ej$Z$ej%Z%ej&Z&dS )aC This module provides a pool manager that uses Google App Engine's `URLFetch Service <https://cloud.google.com/appengine/docs/python/urlfetch>`_. Example usage:: from urllib3 import PoolManager from urllib3.contrib.appengine import AppEngineManager, is_appengine_sandbox if is_appengine_sandbox(): # AppEngineManager uses AppEngine's URLFetch API behind the scenes http = AppEngineManager() else: # PoolManager uses a socket-level API behind the scenes http = PoolManager() r = http.request('GET', 'https://google.com/') There are `limitations <https://cloud.google.com/appengine/docs/python/urlfetch/#Python_Quotas_and_limits>`_ to the URLFetch service and it may not be the best choice for your application. There are three options for using urllib3 on Google App Engine: 1. You can use :class:`AppEngineManager` with URLFetch. URLFetch is cost-effective in many circumstances as long as your usage is within the limitations. 2. You can use a normal :class:`~urllib3.PoolManager` by enabling sockets. Sockets also have `limitations and restrictions <https://cloud.google.com/appengine/docs/python/sockets/ #limitations-and-restrictions>`_ and have a lower free quota than URLFetch. To use sockets, be sure to specify the following in your ``app.yaml``:: env_variables: GAE_USE_SOCKETS_HTTPLIB : 'true' 3. If you are using `App Engine Flexible <https://cloud.google.com/appengine/docs/flexible/>`_, you can use the standard :class:`PoolManager` without any configuration or special environment variables. � )�absolute_importN� )� HTTPError�HTTPWarning� MaxRetryError� ProtocolError�SSLError�TimeoutError)�urljoin)�RequestMethods)�HTTPResponse)�Retry)�Timeout� )�_appengine_environ)�urlfetchc @ s e Zd ZdS )�AppEnginePlatformWarningN��__name__� __module__�__qualname__� r r �J/opt/alt/python38/lib/python3.8/site-packages/urllib3/contrib/appengine.pyr G s r c @ s e Zd ZdS )�AppEnginePlatformErrorNr r r r r r K s r c @ sX e Zd ZdZddd�Zdd� Zdd � Zddddejfd d�Z dd � Z dd� Zdd� ZdS )�AppEngineManagera Connection manager for Google App Engine sandbox applications. This manager uses the URLFetch service directly instead of using the emulated httplib, and is subject to URLFetch limitations as described in the App Engine documentation `here <https://cloud.google.com/appengine/docs/python/urlfetch>`_. Notably it will raise an :class:`AppEnginePlatformError` if: * URLFetch is not available. * If you attempt to use this on App Engine Flexible, as full socket support is available. * If a request size is more than 10 megabytes. * If a response size is more than 32 megabytes. * If you use an unsupported request method such as OPTIONS. Beyond those cases, it will raise normal urllib3 errors. NTc C s@ t std��t�dt� t�| |� || _|| _|p8t j | _d S )Nz.URLFetch is not available in this environment.z�urllib3 is using URLFetch on Google App Engine sandbox instead of sockets. To use sockets directly instead of URLFetch see https://urllib3.readthedocs.io/en/1.26.x/reference/urllib3.contrib.html.)r r �warnings�warnr r �__init__�validate_certificate�urlfetch_retriesr �DEFAULT�retries)�self�headersr! r r r r r r c s ��zAppEngineManager.__init__c C s | S )Nr )r"