Fix HTTPS URL support (#411)
* Fix scheme for HTTPS URLs For URLs like https://example.org scheme is currently set to 'http'. * Revert "Fix scheme for HTTPS URLs" This reverts commit 5dcee5bd2a8ce4453b495e637b283e7558718262. * Fix HTTPS URL support
This commit is contained in:
committed by
Honza Král
parent
5e0627bcfe
commit
9f2608c469
@@ -26,14 +26,15 @@ class Connection(object):
|
||||
"""
|
||||
transport_schema = 'http'
|
||||
|
||||
def __init__(self, host='localhost', port=9200, url_prefix='', timeout=10, **kwargs):
|
||||
def __init__(self, host='localhost', port=9200, use_ssl=False, url_prefix='', timeout=10, **kwargs):
|
||||
"""
|
||||
: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)
|
||||
"""
|
||||
self.host = '%s://%s:%s' % (self.transport_schema, host, port)
|
||||
scheme = 'https' if use_ssl else 'http'
|
||||
self.host = '%s://%s:%s' % (scheme, host, port)
|
||||
if url_prefix:
|
||||
url_prefix = '/' + url_prefix.strip('/')
|
||||
self.url_prefix = url_prefix
|
||||
|
||||
@@ -39,7 +39,7 @@ class Urllib3HttpConnection(Connection):
|
||||
client_key=None, ssl_version=None, ssl_assert_hostname=None,
|
||||
ssl_assert_fingerprint=None, maxsize=10, **kwargs):
|
||||
|
||||
super(Urllib3HttpConnection, self).__init__(host=host, port=port, **kwargs)
|
||||
super(Urllib3HttpConnection, self).__init__(host=host, port=port, use_ssl=use_ssl, **kwargs)
|
||||
self.headers = urllib3.make_headers(keep_alive=True)
|
||||
if http_auth is not None:
|
||||
if isinstance(http_auth, (tuple, list)):
|
||||
|
||||
Reference in New Issue
Block a user