diff --git a/requirements/requirements-development.txt b/requirements/requirements-development.txt index b271ddb..ca6a805 100644 --- a/requirements/requirements-development.txt +++ b/requirements/requirements-development.txt @@ -1,3 +1,4 @@ django>=1.8 djangorestframework>=3.1.0 requests>=1.1.0 +six diff --git a/rest_framework_proxy/views.py b/rest_framework_proxy/views.py index 0fec330..43cc7b3 100644 --- a/rest_framework_proxy/views.py +++ b/rest_framework_proxy/views.py @@ -2,8 +2,13 @@ import json import requests -from django.utils import six -from django.utils.six import BytesIO as StringIO +try: + from django.utils import six + from django.utils.six import BytesIO as StringIO +except ImportError: + import six + from six import BytesIO as StringIO + from requests.exceptions import ConnectionError, SSLError, Timeout from requests import sessions from django.http import HttpResponse @@ -90,10 +95,12 @@ def get_headers(self, request): auth_token = '%s:%s' % (username, password) auth_token = base64.b64encode(auth_token.encode('utf-8')).decode() headers['Authorization'] = 'Basic %s' % auth_token - else: - auth_token = self.proxy_settings.AUTH.get('token') - if auth_token: - headers['Authorization'] = auth_token + return headers + auth_token = self.proxy_settings.AUTH.get('token') + if auth_token: + headers['Authorization'] = auth_token + return headers + headers.update(self.proxy_settings.AUTH) return headers def get_verify_ssl(self, request): diff --git a/setup.py b/setup.py index e35459c..b53ee02 100755 --- a/setup.py +++ b/setup.py @@ -17,7 +17,8 @@ install_requires = [ 'django>=1.8', 'djangorestframework>=3.1.0', - 'requests>=1.1.0' + 'requests>=1.1.0', + 'six' ] classifiers = [ 'Environment :: Web Environment',