ok

Mini Shell

Direktori : /opt/alt/python36/lib/python3.6/site-packages/pip/_vendor/urllib3/contrib/
Upload File :
Current File : //opt/alt/python36/lib/python3.6/site-packages/pip/_vendor/urllib3/contrib/appengine.pyo

�
Bu�_c@@sxdZddlmZddlZddlZddlZddlmZddlm	Z	m
Z
mZmZm
Z
mZddlmZddlmZdd	lmZdd
lmZddlmZydd
lmZWnek
r�dZnXeje�Zde
fd��YZ de	fd��YZ!defd��YZ"ej#Z#ej$Z$ej%Z%ej&Z&ej'Z'dS(s[
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 pip._vendor.urllib3 import PoolManager
    from pip._vendor.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.
i(tabsolute_importNi(turljoin(t	HTTPErrortHTTPWarningt
MaxRetryErrort
ProtocolErrortTimeoutErrortSSLError(tRequestMethods(tHTTPResponse(tTimeout(tRetryi(t_appengine_environ(turlfetchtAppEnginePlatformWarningcB@seZRS((t__name__t
__module__(((sV/opt/alt/python36/lib/python3.6/site-packages/pip/_vendor/urllib3/contrib/appengine.pyRGstAppEnginePlatformErrorcB@seZRS((RR(((sV/opt/alt/python36/lib/python3.6/site-packages/pip/_vendor/urllib3/contrib/appengine.pyRKstAppEngineManagercB@skeZdZddeed�Zd�Zd�Zdddeej	d�Z
d�Zd�Zd�Z
RS(	s
    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 megabtyes.
        * If you use an unsupported request method such as OPTIONS.

    Beyond those cases, it will raise normal urllib3 errors.
    cC@s]tstd��ntjdt�tj||�||_||_|pSt	j
|_dS(Ns.URLFetch is not available in this environment.s�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/latest/reference/urllib3.contrib.html.(R
RtwarningstwarnRRt__init__tvalidate_certificateturlfetch_retriesRtDEFAULTtretries(tselftheadersRRR((sV/opt/alt/python36/lib/python3.6/site-packages/pip/_vendor/urllib3/contrib/appengine.pyRcs		cC@s|S(N((R((sV/opt/alt/python36/lib/python3.6/site-packages/pip/_vendor/urllib3/contrib/appengine.pyt	__enter__|scC@stS(N(tFalse(Rtexc_typetexc_valtexc_tb((sV/opt/alt/python36/lib/python3.6/site-packages/pip/_vendor/urllib3/contrib/appengine.pyt__exit__scK@sk|j||�}yv|o0|jdko0|j}	tj|d|d|d|pTidtd|joi|	d|j|�d|j�}
Wn"tj	k
r�}t
||��n�tjk
r�}d	t|�kr�t
d
|��nt|��n�tjk
r?}dt|�kr0t||d|��nt|��nntjk
rc}t
d
|��nJtjk
r�}t|��n)tjk
r�}t
d||��nX|j|
d||�}|o�|j�}
|
r�|jr|jrt||d��q�|jdkrd}ny"|j||d|d|�}Wn0tk
rp|jrlt||d��n|SX|j|�tjd||
�t||
�}|j||||d|d|d||�Snt|j d��}|j!||j|�rg|j||d|d|�}tjd|�|j"|�|j||d|d|d|d|d||�S|S(NitpayloadtmethodRtallow_truncatedtfollow_redirectstdeadlineRs	too largesOURLFetch request too large, URLFetch only supports requests up to 10mb in size.sToo many redirectstreasonsPURLFetch response too large, URLFetch only supportsresponses up to 32mb in size.s$URLFetch does not support method: %sRstoo many redirectsi/tGETtresponset_poolsRedirecting %s -> %stredirectttimeoutsRetry-Afters	Retry: %stbody(#t_get_retriesR+ttotalR
tfetchRRt_get_absolute_timeoutRtDeadlineExceededErrorRtInvalidURLErrortstrRRt
DownloadErrorRtResponseTooLargeErrortSSLCertificateErrorRtInvalidMethodErrort#_urlfetch_response_to_http_responsetget_redirect_locationtraise_on_redirecttstatust	incrementtsleep_for_retrytlogtdebugRturlopentboolt	getheadertis_retrytsleep(RR#turlR-RRR+R,tresponse_kwR%R)tet
http_responsetredirect_locationtredirect_urlthas_retry_after((sV/opt/alt/python36/lib/python3.6/site-packages/pip/_vendor/urllib3/contrib/appengine.pyRA�s�	
	


c
K@s�t�r7|jjd�}|dkr7|jd=q7n|jjd�}|dkr�|jd�}|jd�dj|�|jd<ntdtj|j	�d|j
d|jd	|j|�}tdtj|j	�d|jd	|jd
||�S(Nscontent-encodingtdeflatestransfer-encodingtchunkedt,R-tmsgRR<toriginal_response(tis_prod_appengineRtgettsplittremovetjoinR	tiotBytesIOtcontentt
header_msgtstatus_code(Rt
urlfetch_respRGtcontent_encodingttransfer_encodingt	encodingsRQ((sV/opt/alt/python36/lib/python3.6/site-packages/pip/_vendor/urllib3/contrib/appengine.pyR9�s*	
					cC@s^|tjkrdSt|t�rZ|jdk	s@|jdk	rStjdt�n|j	S|S(NsdURLFetch does not support granular timeout settings, reverting to total or default URLFetch timeout.(
R
tDEFAULT_TIMEOUTtNonet
isinstancet_readt_connectRRRR/(RR,((sV/opt/alt/python36/lib/python3.6/site-packages/pip/_vendor/urllib3/contrib/appengine.pyR1s
cC@sbt|t�s0tj|d|d|j�}n|jsK|jsK|jr^tjdt	�n|S(NR+tdefaultshURLFetch only supports total retries and does not recognize connect, read, or redirect retry parameters.(
RbRtfrom_intRtconnecttreadR+RRR(RRR+((sV/opt/alt/python36/lib/python3.6/site-packages/pip/_vendor/urllib3/contrib/appengine.pyR.&s!
N(RRt__doc__RatTrueRRR!R
R`RAR9R1R.(((sV/opt/alt/python36/lib/python3.6/site-packages/pip/_vendor/urllib3/contrib/appengine.pyROs		j	$	
((Rit
__future__RRWtloggingRtpackages.six.moves.urllib.parseRt
exceptionsRRRRRRtrequestRR)R	tutil.timeoutR
t
util.retryRtRtgoogle.appengine.apiR
tImportErrorRat	getLoggerRR?RRRtis_appenginetis_appengine_sandboxtis_local_appengineRRtis_prod_appengine_mvms(((sV/opt/alt/python36/lib/python3.6/site-packages/pip/_vendor/urllib3/contrib/appengine.pyt<module>'s0.	

�				

Zerion Mini Shell 1.0