Skip to content
Open
Show file tree
Hide file tree
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
1 change: 1 addition & 0 deletions requirements/requirements-development.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
django>=1.8
djangorestframework>=3.1.0
requests>=1.1.0
six
19 changes: 13 additions & 6 deletions rest_framework_proxy/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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):
Expand Down
3 changes: 2 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down