Skip to content

Commit

Permalink
Merge pull request #13 from lextoumbourou/https-support
Browse files Browse the repository at this point in the history
#11: Allow HTTPS in url.
  • Loading branch information
lextoumbourou committed Apr 10, 2016
2 parents 2c8d78e + 85e1788 commit 461957c
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 1 deletion.
5 changes: 5 additions & 0 deletions tests/test_connection_http.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,11 @@ def test_prepare_url(self):
result = _prepare_url('s1', 'index/doc/_search', {'size': 5})
self.assertTrue(result == 'http://s1/index/doc/_search?size=5')

def test_prepare_url_handles_ssl(self):
result = _prepare_url(
'https://s1:443', 'index/doc/_search', {'size': 5})
self.assertTrue(result == 'https://s1:443/index/doc/_search?size=5')

@patch('txes2.connection_http.treq')
@inlineCallbacks
def test_execute(self, treq_mock):
Expand Down
2 changes: 1 addition & 1 deletion txes2/connection_http.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ def _prepare_url(server, path, params):
if params:
url = url + '?' + urllib.urlencode(params)

if not url.startswith("http://"):
if not url.startswith(('http:', 'https:')):
url = "http://" + url

return url.encode('utf-8')
Expand Down
2 changes: 2 additions & 0 deletions txes2/elasticsearch.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ def __init__(self, servers='127.0.0.1:9200', timeout=30, bulk_size=400,
default_indexes=None, autorefresh=False, *args, **kwargs):
"""
:param servers: either a single ES server URL or list of servers.
If you don't provide a scheme (eg `https://`) then the
request will use HTTP by default.
:param int timeout: connection timeout in seconds.
:param int bulk_size: how much bulk data to accumulate before indexing
(when indexing in bulk).
Expand Down

0 comments on commit 461957c

Please sign in to comment.