a Y@sddlZddlZddlmZmZddlZdZzddlZe ZWne yRYn0ddl m Z ddl mZmZmZmZddlmZGdd d e ZdS) N)ReadTimeoutErrorSSLError) Connection)ConnectionErrorImproperlyConfiguredConnectionTimeoutr) urlencodec s4eZdZdZdfdd Zdd d Zd dZZS)Urllib3HttpConnectionaT Default connection class using the `urllib3` library and the http protocol. :arg host: hostname of the node (default: localhost) :arg port: port to use (integer, default: 9200) :arg url_prefix: optional url prefix for elasticsearch :arg timeout: default timeout in seconds (float, default: 10) :arg http_auth: optional http auth information as either ':' separated string or a tuple :arg use_ssl: use ssl for the connection if `True` :arg verify_certs: whether to verify SSL certificates :arg ca_certs: optional path to CA bundle. See https://urllib3.readthedocs.io/en/latest/security.html#using-certifi-with-urllib3 for instructions how to get default set :arg client_cert: path to the file containing the private key and the certificate, or cert only if using client_key :arg client_key: path to the file containing the private key if using separate cert and key files (client_cert will contain only the cert) :arg ssl_version: version of the SSL protocol to use. Choices are: SSLv23 (default) SSLv2 SSLv3 TLSv1 (see ``PROTOCOL_*`` constants in the ``ssl`` module for exact options for your environment). :arg ssl_assert_hostname: use hostname verification if not `False` :arg ssl_assert_fingerprint: verify the supplied certificate fingerprint if not `None` :arg maxsize: the number of connections which will be kept open to this host. See https://urllib3.readthedocs.io/en/1.4/pools.html#api for more information. :arg headers: any custom http headers to be add to requests localhost#NFT c stt|jf|||d|tjdd|_|dur`t|ttfrLd |}|j tj|d| r| D]}| ||j| <qh|j dd|durt n|}tj}i}|rtj}| | | | d|r|std | d |||d ntd |||f||j| d ||_dS)N)hostportuse_sslT) keep_alive:) basic_authz content-typezapplication/json) ssl_versionassert_hostnameassert_fingerprintzRoot certificates are missing for certificate validation. Either pass them in using the ca_certs parameter or install certifi to use it automatically. CERT_REQUIRED) cert_reqsca_certs cert_filekey_filez?Connecting to %s using SSL with verify_certs=False is insecure.)rtimeoutmaxsize)superr __init__urllib3 make_headersheaders isinstancetuplelistjoinupdatelower setdefaultCA_CERTSHTTPConnectionPoolHTTPSConnectionPoolrwarningswarnrpool)selfrr http_authr verify_certsr client_cert client_keyrZssl_assert_hostnameZssl_assert_fingerprintrr#kwargskZ pool_classkw __class__L/Users/ymaher/Downloads/lambdas_org/elasticsearch/connection/http_urllib3.pyr /sB  zUrllib3HttpConnection.__init__r;c Cs|j|}|rd|t|f}|j|}t}zti} |rB|| d<t|tsV|d}t|tsj|d}|jj|||fd|j d| } t|} | j d} Wnt y.} zp|j ||||t|| dt| trtdt| | t| tr tdt| | tdt| | WYd} ~ n d} ~ 00d | jkrJd ks~n| j|vr~| ||||| | j| || j| |||||| j| | | j| | fS) Nz%s?%srzutf-8F)retriesr#) exceptionzN/ATIMEOUTi,) url_prefixr rtimer$strencoder0urlopenr#datadecode Exceptionlog_request_failUrllibSSLErrorrrr rstatus _raise_errorlog_request_success getheaders)r1methodurlparamsbodyrignorefull_urlstartr8responsedurationraw_dataer;r;r<perform_request^s<          &(z%Urllib3HttpConnection.perform_requestcCs|jdS)z. Explicitly closes connection N)r0close)r1r;r;r<r[szUrllib3HttpConnection.close) r r NFTNNNNNNrN)NNNr;)__name__ __module__ __qualname____doc__r rZr[ __classcell__r;r;r9r<r s/ )r )rBr!Zurllib3.exceptionsrrrJr.r+Zcertifiwhere ImportErrorbaser exceptionsrrr compatr r r;r;r;r<s