Skip to content

Modify test for http_auth to allow for passing custom authentication met... #210

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 26, 2015
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions elasticsearch/connection/http_requests.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import six
import time
import warnings
try:
Expand Down Expand Up @@ -32,8 +33,10 @@ def __init__(self, host='localhost', port=9200, http_auth=None,
super(RequestsHttpConnection, self).__init__(host= host, port=port, **kwargs)
self.session = requests.session()
if http_auth is not None:
if not isinstance(http_auth, (tuple, list)):
http_auth = http_auth.split(':', 1)
if isinstance(http_auth, (tuple, list)):
http_auth = tuple(http_auth)
elif isinstance(http_auth, six.string_types):
http_auth = tuple(http_auth.split(':', 1))
http_auth = tuple(http_auth)
self.session.auth = http_auth
self.base_url = 'http%s://%s:%d%s' % (
Expand Down