Viewing File: /opt/alt/python35/lib/python3.5/site-packages/urllib3/contrib/__pycache__/appengine.cpython-35.pyc



V@srddlmZddlZddlZddlZddlmZmZmZm	Z	m
Z
mZddlm
Z
ddlmZddlmZddlmZdd	lmZydd
lmZWnek
rdZYnXejeZGdddeZGd
ddeZGdddeZddZddZ ddZ!ddZ"ddZ#dS))absolute_importN)	HTTPErrorHTTPWarning
MaxRetryError
ProtocolErrorTimeoutErrorSSLError)BytesIO)RequestMethods)HTTPResponse)Timeout)Retry)urlfetchc@seZdZdS)AppEnginePlatformWarningN)__name__
__module____qualname__rr
/appengine.pyrsrc@seZdZdS)AppEnginePlatformErrorN)rrrrrrrr"src@seZdZdZdddddZddZdd	Zddddejd
dZ	dd
Z
ddZddZdS)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 AppEnginePlatformError if:
        * URLFetch is not available.
        * If you attempt to use this on GAEv2 (Managed VMs), 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.
    NTcCsftstdtr'tdtjdttj||||_|p\t	j
|_dS)Nz.URLFetch is not available in this environment.zUse normal urllib3.PoolManager instead of AppEngineManageron Managed VMs, as using URLFetch is not necessary in this environment.zurllib3 is using URLFetch on Google App Engine sandbox instead of sockets. To use sockets directly instead of URLFetch see https://urllib3.readthedocs.org/en/latest/contrib.html.)rris_prod_appengine_mvmswarningswarnrr__init__validate_certificaterZDEFAULTretries)selfheadersrrrrrr;s				zAppEngineManager.__init__cCs|S)Nr)rrrr	__enter__QszAppEngineManager.__enter__cCsdS)NFr)rexc_typeexc_valexc_tbrrr__exit__TszAppEngineManager.__exit__cKs|j||}ygtj|d|d|d|p6iddd|oZ|jdkoZ|jd|j|d	|j}	Wntjk
r}
zt||
WYdd}
~
XnRtj	k
r}
z2d
t
|
krtd|
t|
WYdd}
~
Xntj
k
r`}
z8dt
|
krBt||d
|
t|
WYdd}
~
Xntjk
r}
ztd|
WYdd}
~
Xnntjk
r}
zt|
WYdd}
~
Xn;tjk
r}
ztd||
WYdd}
~
XnX|j|	|}|jrC|jrC|rCt||d|j|d|jr|j||d|d|}tjd||j|j||d|d|d|d|d||S|S)NpayloadmethodrZallow_truncatedFZfollow_redirectsrdeadlinerz	too largezOURLFetch request too large, URLFetch only supports requests up to 10mb in size.zToo many redirectsreasonzPURLFetch response too large, URLFetch only supportsresponses up to 32mb in size.z$URLFetch does not support method: %sztoo many redirectsstatus_coderesponseZ_poolzForced retry: %sbodyrredirecttimeout)_get_retriesrZfetchr,total_get_absolute_timeoutrZDeadlineExceededErrorrZInvalidURLErrorstrrrZ
DownloadErrorrZResponseTooLargeErrorZSSLCertificateErrorr	ZInvalidMethodError#_urlfetch_response_to_http_responseZget_redirect_locationZraise_on_redirectZis_forced_retrystatusZ	incrementloginfosleepurlopen)rr&Zurlr+rrr,r-response_kwr*eZ
http_responserrrr7Xsd	!	#
	
zAppEngineManager.urlopencKstr1|jjd}|dkr1|jd=|jjd}|dkr|jd}|jddj||jd<tdt|jd|jd|j	|S)	Nzcontent-encodingZdeflateztransfer-encodingZchunked,r+rr3)
is_prod_appenginergetsplitremovejoinrr
Zcontentr))rZ
urlfetch_respr8Zcontent_encodingZtransfer_encoding	encodingsrrrr2s	

	z4AppEngineManager._urlfetch_response_to_http_responsecCsO|tjkrdSt|trK|j|jk	rDtjdt|jS|S)NzPURLFetch does not support granular timeout settings, reverting to total timeout.)	r
DEFAULT_TIMEOUT
isinstance_readZ_connectrrrr/)rr-rrrr0sz&AppEngineManager._get_absolute_timeoutcCs\t|ts-tj|d|d|j}|jsH|jsH|jrXtjdt	|S)Nr,defaultzhURLFetch only supports total retries and does not recognize connect, read, or redirect retry parameters.)
rCrZfrom_intrconnectreadr,rrr)rrr,rrrr.szAppEngineManager._get_retries)
rrr__doc__rr r$r
rBr7r2r0r.rrrrr&sDrcCstptptS)N)is_local_appenginer;rrrrris_appengines		rJcCstotS)N)rJrrrrris_appengine_sandboxsrKcCs dtjkodtjdkS)NAPPENGINE_RUNTIMEzDevelopment/SERVER_SOFTWARE)osenvironrrrrrIsrIcCs*dtjko)dtjdko)tS)NrLzGoogle App Engine/rM)rNrOrrrrrr;sr;cCstjjdddkS)NZGAE_VMFtrue)rNrOr<rrrrrsr)$Z
__future__rloggingrNr
exceptionsrrrrrr	Zpackages.sixr
Zrequestrr*rZutil.timeoutr
Z
util.retryrZgoogle.appengine.apirImportError	getLoggerrr4rrrrJrKrIr;rrrrr<module>s,.	

Back to Directory File Manager