ó >´­_c@@s*ddlmZddlZddlZddlZddlmZddlmZm Z m Z ddl m Z m Z mZmZmZddlmZddlmZdd lmZdd lmZdd lmZdd lmZd ddgZejeƒZ ddddddddfZ!ddddddddd d!d"d#d$d%d&d'd(d)d*d+d,d-d.d/d0d1fZ"ej#d2e"ƒZ$dd3fZ%ej#d4e%ƒZ&d5„Z'iej(e'e$ƒd66ej(e'e$ƒd76Z)ied66e d76Z*d efd8„ƒYZ+de+fd9„ƒYZ,d:„Z-dS(;i(tabsolute_importNi(tRecentlyUsedContainer(tHTTPConnectionPooltHTTPSConnectionPooltport_by_scheme(tLocationValueErrort MaxRetryErrortProxySchemeUnknowntProxySchemeUnsupportedtURLSchemeUnknown(tsix(turljoin(tRequestMethods(tconnection_requires_http_tunnel(tRetry(t parse_urlt PoolManagert ProxyManagertproxy_from_urltkey_filet cert_filet cert_reqstca_certst ssl_versiont ca_cert_dirt ssl_contextt key_passwordt key_schemetkey_hosttkey_portt key_timeoutt key_retriest key_strictt key_blocktkey_source_addresst key_key_filetkey_key_passwordt key_cert_filet key_cert_reqst key_ca_certstkey_ssl_versiontkey_ca_cert_dirtkey_ssl_contextt key_maxsizet key_headerst key__proxytkey__proxy_headerstkey__proxy_configtkey_socket_optionstkey__socks_optionstkey_assert_hostnametkey_assert_fingerprinttkey_server_hostnametPoolKeytuse_forwarding_for_httpst ProxyConfigcC@s|jƒ}|djƒ|d<|djƒ|d/opt/awscli/lib/python2.7/site-packages/urllib3/poolmanager.pyt_default_key_normalizerNs  !  thttpthttpscB@sªeZdZdZdZddd„Zd„Zd„Zdd„Z d„Z dddd„Z d „Z dd „Z dd „Zd „Zd „Zd„Zed„ZRS(s$ Allows for arbitrary requests while transparently keeping track of necessary connection pools for you. :param num_pools: Number of connection pools to cache before discarding the least recently used pool. :param headers: Headers to include with all requests, unless other headers are given explicitly. :param \**connection_pool_kw: Additional parameters are used to create fresh :class:`urllib3.connectionpool.ConnectionPool` instances. Example:: >>> manager = PoolManager(num_pools=2) >>> r = manager.request('GET', 'http://google.com/') >>> r = manager.request('GET', 'http://google.com/mail') >>> r = manager.request('GET', 'http://yahoo.com/') >>> len(manager.pools) 2 i cK@sMtj||ƒ||_t|dd„ƒ|_t|_tjƒ|_dS(Nt dispose_funccS@s |jƒS(N(tclose(tp((s>/opt/awscli/lib/python2.7/site-packages/urllib3/poolmanager.pyt­t(R t__init__tconnection_pool_kwRtpoolstpool_classes_by_schemetkey_fn_by_schemeR?(tselft num_poolsR:RY((s>/opt/awscli/lib/python2.7/site-packages/urllib3/poolmanager.pyRXªs   cC@s|S(N((R]((s>/opt/awscli/lib/python2.7/site-packages/urllib3/poolmanager.pyt __enter__´scC@s|jƒtS(N(tcleartFalse(R]texc_typetexc_valtexc_tb((s>/opt/awscli/lib/python2.7/site-packages/urllib3/poolmanager.pyt__exit__·s cC@sŒ|j|}|dkr+|jjƒ}nxdD]}|j|dƒq2W|dkr|x!tD]}|j|dƒq_Wn||||S(sÎ Create a new :class:`urllib3.connectionpool.ConnectionPool` based on host, port, scheme, and any additional pool keyword arguments. If ``request_context`` is provided, it is provided as keyword arguments to the pool class used. This method is used to actually create the connection pools handed out by :meth:`connection_from_url` and companion methods. It is intended to be overridden for customization. R8R9tportRQN(R8R9Rf(R[RARYR?RHt SSL_KEYWORDS(R]R8R9RfRKtpool_clsRMtkw((s>/opt/awscli/lib/python2.7/site-packages/urllib3/poolmanager.pyt _new_pool¼s     cC@s|jjƒdS(s´ Empty our store of pools and direct them all to close. This will not affect in-flight connections, but they will not be re-used after completion. N(RZR`(R]((s>/opt/awscli/lib/python2.7/site-packages/urllib3/poolmanager.pyR`×sRQcC@sz|stdƒ‚n|j|ƒ}|p-d|d<|sYtj|djƒdƒ}n||d<||d<|j|ƒS(s¤ Get a :class:`urllib3.connectionpool.ConnectionPool` based on the host, port, and scheme. If ``port`` isn't given, it will be derived from the ``scheme`` using ``urllib3.connectionpool.port_by_scheme``. If ``pool_kwargs`` is provided, it is merged with the instance's ``connection_pool_kw`` variable and used to create the new connection pool, if one is needed. sNo host specified.RQR8iPRfR9(Rt_merge_pool_kwargsRRDR@tconnection_from_context(R]R9RfR8t pool_kwargsRK((s>/opt/awscli/lib/python2.7/site-packages/urllib3/poolmanager.pytconnection_from_hostàs   cC@sV|djƒ}|jj|ƒ}|s7t|ƒ‚n||ƒ}|j|d|ƒS(sù Get a :class:`urllib3.connectionpool.ConnectionPool` based on the request context. ``request_context`` must at least contain the ``scheme`` key and its value must be a key in ``key_fn_by_scheme`` instance variable. R8RK(R@R\RDR tconnection_from_pool_key(R]RKR8tpool_key_constructortpool_key((s>/opt/awscli/lib/python2.7/site-packages/urllib3/poolmanager.pyRl÷s  c C@sy|jjg|jj|ƒ}|r)|S|d}|d}|d}|j|||d|ƒ}||j|/opt/awscli/lib/python2.7/site-packages/urllib3/poolmanager.pyRos    cC@s4t|ƒ}|j|jd|jd|jd|ƒS(sÖ Similar to :func:`urllib3.connectionpool.connection_from_url`. If ``pool_kwargs`` is not provided and a new pool needs to be constructed, ``self.connection_pool_kw`` is used to initialize the :class:`urllib3.connectionpool.ConnectionPool`. If ``pool_kwargs`` is provided, it is used instead. Note that if a new pool does not need to be created for the request, the provided ``pool_kwargs`` are not used. RfR8Rm(RRnR9RfR8(R]turlRmtu((s>/opt/awscli/lib/python2.7/site-packages/urllib3/poolmanager.pytconnection_from_urls cC@sq|jjƒ}|rmxU|jƒD]D\}}|dkr\y ||=Wqftk rXqfXq"|||/opt/awscli/lib/python2.7/site-packages/urllib3/poolmanager.pyRk.s   cC@s-|jdkrtSt|j|j|jƒ S(s³ Indicates if the proxy requires the complete destination URL in the request. Normally this is only needed when not using an HTTP CONNECT tunnel. N(tproxyRARaR t proxy_configR8(R]t parsed_url((s>/opt/awscli/lib/python2.7/site-packages/urllib3/poolmanager.pyt!_proxy_requires_url_absolute_formBscC@s^|jdks|dkrdS|jjdkr5dStjrZ|jj rZtdƒ‚ndS(s Validates that were not attempting to do TLS in TLS connections on Python2 or with unsupported SSL implementations. RRNsfContacting HTTPS destinations through HTTPS proxies 'via CONNECT tunnels' is not supported in Python 2(R{RAR8R tPY2R|R6R(R]t url_scheme((s>/opt/awscli/lib/python2.7/site-packages/urllib3/poolmanager.pyt$_validate_proxy_scheme_url_selectionOsc K@s4t|ƒ}|j|jƒ|j|jd|jd|jƒ}t|d %sN(!RRR8RnR9RfRaR:R?R~turlopent request_uritget_redirect_locationR tstatusRDt isinstanceRtfrom_inttremove_headers_on_redirectt is_same_hostRFR titerkeysR@RHRAt incrementRtraise_on_redirectt drain_conntlogtinfo( R]tmethodRtRƒRiRutconnR†tredirect_locationR…R:theader((s>/opt/awscli/lib/python2.7/site-packages/urllib3/poolmanager.pyRˆ`sJ $      "      N(t__name__t __module__t__doc__RAR{R|RXR_ReRjR`RnRlRoRvRkR~RtTrueRˆ(((s>/opt/awscli/lib/python2.7/site-packages/urllib3/poolmanager.pyR‹s          cB@sPeZdZdddded„Zdddd„Zdd„Zed„Z RS(s> Behaves just like :class:`PoolManager`, but sends all requests through the defined proxy, using the CONNECT method for HTTPS URLs. :param proxy_url: The URL of the proxy to be used. :param proxy_headers: A dictionary containing headers that will be sent to the proxy. In case of HTTP they are being sent with each request, while in the HTTPS/CONNECT case they are sent only once. Could be used for proxy authentication. :param proxy_ssl_context: The proxy SSL context is used to establish the TLS connection to the proxy when using HTTPS proxies. :param use_forwarding_for_https: (Defaults to False) If set to True will forward requests to the HTTPS proxy to be made on behalf of the client instead of creating a TLS tunnel via the CONNECT method. **Enabling this flag means that request and response headers and content will be visible from the HTTPS proxy** whereas tunneling keeps request and response headers and content private. IP address, target hostname, SNI, and port are always visible to an HTTPS proxy even when this flag is disabled. Example: >>> proxy = urllib3.ProxyManager('http://localhost:3128/') >>> r1 = proxy.request('GET', 'http://google.com/') >>> r2 = proxy.request('GET', 'http://httpbin.org/') >>> len(proxy.pools) 1 >>> r3 = proxy.request('GET', 'https://httpbin.org/') >>> r4 = proxy.request('GET', 'https://twitter.com/') >>> len(proxy.pools) 3 i c K@st|tƒr.d|j|j|jf}nt|ƒ}|jd kr[t|jƒ‚n|jsŽtj|jdƒ} |j d| ƒ}n||_ |p i|_ ||_ t ||ƒ|_|j |d<|j |d<|j|d/opt/awscli/lib/python2.7/site-packages/urllib3/poolmanager.pyRXÌs&        RQcC@sb|dkr.tt|ƒj|||d|ƒStt|ƒj|jj|jj|jjd|ƒS(NRRRm(R£RRnR{R9RfR8(R]R9RfR8Rm((s>/opt/awscli/lib/python2.7/site-packages/urllib3/poolmanager.pyRnñs  cC@sIidd6}t|ƒj}|r/||d/opt/awscli/lib/python2.7/site-packages/urllib3/poolmanager.pyt_set_proxy_headersûs  cK@swt|ƒ}t|j|j|jƒsU|jd|jƒ}|j||ƒ|d/opt/awscli/lib/python2.7/site-packages/urllib3/poolmanager.pyRˆ s  N( RšR›RœRARaRXRnRªRRˆ(((s>/opt/awscli/lib/python2.7/site-packages/urllib3/poolmanager.pyR¤s&  cK@std||S(NR¤(R(RtRi((s>/opt/awscli/lib/python2.7/site-packages/urllib3/poolmanager.pyRs(.t __future__Rt collectionst functoolstloggingt _collectionsRtconnectionpoolRRRt exceptionsRRRRR tpackagesR tpackages.six.moves.urllib.parseR trequestR t util.proxyR t util.retryRtutil.urlRt__all__t getLoggerRšR”Rgt _key_fieldst namedtupleR5t_proxy_config_fieldsR7RPtpartialR\R[RRR(((s>/opt/awscli/lib/python2.7/site-packages/urllib3/poolmanager.pytsx   (    5ÿs