t_c@sJddlZddlZddlZddlmZddlmZmZm Z m Z ddl m Z ddl mZmZmZmZmZddlmZddlmZddlmZdd lmZmZmZydd lmZWn!e k rdd l mZnXddl!Z"dd l#m$Z$dd l%m&Z&ddl'm(Z(m)Z)ddl*m+Z+m,Z,m-Z-mZm.Z.mZmZe(ej/e0Z1dZ2dZ3ej4j5ej4j6e7dZ8yddl9m:Z:Wne k rdZ:nXdZ;dddddZ=de>fdYZ?de>fdYZ@dS(iN(t b64encode(t PoolManagert ProxyManagertproxy_from_urltTimeout(tRetry(tsslt OP_NO_SSLv2t OP_NO_SSLv3tOP_NO_COMPRESSIONtDEFAULT_CIPHERS(tSSLError(tReadTimeoutError(tConnectTimeoutError(tNewConnectionErrort ProtocolErrort ProxyError(torig_util_SSLContext(t SSLContext(tsix(tunquote(tfilter_ssl_warningsturlparse(tConnectionClosedErrortEndpointConnectionErrortHTTPClientErrorR tProxyConnectionErrorR R i<i s cacert.pem(twherecCstS(N(tDEFAULT_CA_BUNDLE(((s?/opt/awscli/lib/python2.7/site-packages/botocore/httpsession.pyR'scCs|tk r|StS(N(tTrueR(tverify((s?/opt/awscli/lib/python2.7/site-packages/botocore/httpsession.pyt get_cert_path+s cCst|ptj}|dkr*tjn|}|dkrcd}|tO}|tO}|tO}n|j|O_t |dt r|j |pt n||_ t |dddk rt|_n|S(s This function is a vendored version of the same function in urllib3 We vendor this function to ensure that the SSL contexts we construct always use the std lib SSLContext instead of pyopenssl. itsupports_set_cipherstcheck_hostnameN(RRtPROTOCOL_SSLv23tNonet CERT_REQUIREDRRR toptionstgetattrRt set_ciphersR t verify_modetFalseR!(t ssl_versiont cert_reqsR%tcipherstcontext((s?/opt/awscli/lib/python2.7/site-packages/botocore/httpsession.pytcreate_urllib3_context2s      tProxyConfigurationcBsGeZdZddZdZdZdZdZdZ RS(sRepresents a proxy configuration dictionary. This class represents a proxy configuration dictionary and provides utility functions to retreive well structured proxy urls and proxy headers from the proxy configuration dictionary. cCs"|dkri}n||_dS(N(R#t_proxies(tselftproxies((s?/opt/awscli/lib/python2.7/site-packages/botocore/httpsession.pyt__init__^s  cCs=t|}|jj|j}|r9|j|}n|S(s7Retrieves the corresponding proxy url for a given url. (RR0tgettschemet_fix_proxy_url(R1turlt parsed_urltproxy((s?/opt/awscli/lib/python2.7/site-packages/botocore/httpsession.pyt proxy_url_forcs  cCsJi}|j|\}}|rF|rF|j||}||d((s?/opt/awscli/lib/python2.7/site-packages/botocore/httpsession.pyt_chunkedsc CsPy|jj|j}|j|j|}|j|j}|j||j|j|j|j|}|jd|j d|d|j d|j dt t dt dt dt d |j|j  }tjj|j|j|j |}|js|jn|SWnCtk r3}td |jd |nttjfk rf}td |jd |ntk r}td |d |ntk r}td |jd |ntk r}t d |jd |nkt!k r}t"d |d |d |jn;t#k rK}d} t$j%| dt&t'd |nXdS(NtmethodR7tbodyR>tretriestassert_same_hosttpreload_contenttdecode_contentRt endpoint_urlterrorR=trequests4Exception received when sending urllib3 HTTP requesttexc_info((RVR:R7Rtconnection_from_urlRRURturlopenRRR>RR)RRWRXt AWSResponsetstatust stream_outputtcontenttURLLib3SSLErrorR RtsockettgaierrorRRRtURLLib3ConnectTimeoutErrorR tURLLib3ReadTimeoutErrorR RRt ExceptiontloggertdebugRR( R1RR=RRtrequest_targetturllib_responset http_responsetetmessage((s?/opt/awscli/lib/python2.7/site-packages/botocore/httpsession.pytsendsV         N(RMRNRORR#tMAX_POOL_CONNECTIONSR3RhRtR{RRRRRR(((s?/opt/awscli/lib/python2.7/site-packages/botocore/httpsession.pyRPs       (Atos.pathtostloggingRtbase64Rturllib3RRRRturllib3.util.retryRturllib3.util.ssl_RRRR R turllib3.exceptionsR RR RR RRRRturllib3.contrib.pyopensslRRt ImportErrortbotocore.awsrequestRWtbotocore.vendoredRt(botocore.vendored.six.moves.urllib_parseRtbotocore.compatRRtbotocore.exceptionsRRRRt getLoggerRMRR\RR~tjointdirnamet__file__RtcertifiRRR#R.tobjectR/RP(((s?/opt/awscli/lib/python2.7/site-packages/botocore/httpsession.pytsB   "(  4!   $2