Skip to content

Commit 9f2608c

Browse files
hudolejevhonzakral
authored andcommitted
Fix HTTPS URL support (elastic#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 5dcee5b. * Fix HTTPS URL support
1 parent 5e0627b commit 9f2608c

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

elasticsearch/connection/base.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,14 +26,15 @@ class Connection(object):
2626
"""
2727
transport_schema = 'http'
2828

29-
def __init__(self, host='localhost', port=9200, url_prefix='', timeout=10, **kwargs):
29+
def __init__(self, host='localhost', port=9200, use_ssl=False, url_prefix='', timeout=10, **kwargs):
3030
"""
3131
:arg host: hostname of the node (default: localhost)
3232
:arg port: port to use (integer, default: 9200)
3333
:arg url_prefix: optional url prefix for elasticsearch
3434
:arg timeout: default timeout in seconds (float, default: 10)
3535
"""
36-
self.host = '%s://%s:%s' % (self.transport_schema, host, port)
36+
scheme = 'https' if use_ssl else 'http'
37+
self.host = '%s://%s:%s' % (scheme, host, port)
3738
if url_prefix:
3839
url_prefix = '/' + url_prefix.strip('/')
3940
self.url_prefix = url_prefix

elasticsearch/connection/http_urllib3.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ def __init__(self, host='localhost', port=9200, http_auth=None,
3939
client_key=None, ssl_version=None, ssl_assert_hostname=None,
4040
ssl_assert_fingerprint=None, maxsize=10, **kwargs):
4141

42-
super(Urllib3HttpConnection, self).__init__(host=host, port=port, **kwargs)
42+
super(Urllib3HttpConnection, self).__init__(host=host, port=port, use_ssl=use_ssl, **kwargs)
4343
self.headers = urllib3.make_headers(keep_alive=True)
4444
if http_auth is not None:
4545
if isinstance(http_auth, (tuple, list)):

0 commit comments

Comments
 (0)