Skip to content

Commit

Permalink
Do not remove AUTHORIZATION header
Browse files Browse the repository at this point in the history
This header should be removed only if basic auth handled by server.
  • Loading branch information
Sergey Skripnick committed Nov 28, 2015
1 parent 0e4f91e commit 30a388b
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 8 deletions.
4 changes: 1 addition & 3 deletions aiohttp/wsgi.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,7 @@ def create_wsgi_environ(self, message, payload):
script_name = self.SCRIPT_NAME

for hdr_name, hdr_value in message.headers.items():
if hdr_name == 'AUTHORIZATION':
continue
elif hdr_name == 'SCRIPT_NAME':
if hdr_name == 'SCRIPT_NAME':
script_name = hdr_value
elif hdr_name == 'CONTENT-TYPE':
environ['CONTENT_TYPE'] = hdr_value
Expand Down
11 changes: 6 additions & 5 deletions tests/test_wsgi.py
Original file line number Diff line number Diff line change
Expand Up @@ -258,14 +258,15 @@ def test_dont_unquote_environ_path_info(self):
environ = self._make_one()
self.assertEqual(environ['PATH_INFO'], path)

def test_not_add_authorization(self):
self.headers.extend({'AUTHORIZATION': 'spam',
'X-CUSTOM-HEADER': 'eggs'})
def test_authorization(self):
# This header should be removed according to CGI/1.1 and WSGI but
# in our case basic auth is not handled by server, so should
# not be removed
self.headers.extend({'AUTHORIZATION': 'spam'})
self.message = protocol.RawRequestMessage(
'GET', '/', (1, 1), self.headers, True, 'deflate')
environ = self._make_one()
self.assertEqual('eggs', environ['HTTP_X_CUSTOM_HEADER'])
self.assertFalse('AUTHORIZATION' in environ)
self.assertEqual('spam', environ['HTTP_AUTHORIZATION'])

def test_http_1_0_no_host(self):
headers = multidict.MultiDict({})
Expand Down

0 comments on commit 30a388b

Please sign in to comment.