Skip to content

Commit

Permalink
Workaround for aio-libs/multidict#11
Browse files Browse the repository at this point in the history
  • Loading branch information
alexdutton committed Sep 22, 2016
1 parent b0d93ef commit e2cea6c
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion apiox/core/middleware/request_logging.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import logging

from aiohttp.web_exceptions import HTTPException
from multidict._multidict import CIMultiDict, MultiDict

from apiox.core.token import generate_token

Expand All @@ -15,7 +16,10 @@ def request_logging_middleware(app, handler):
def middleware(request):
start_dt = datetime.datetime.now(tz=datetime.timezone.utc)
server_name, server_port, *_ = request.transport.get_extra_info('sockname')
headers = request.headers.copy()
assert isinstance(request.headers, MultiDict)
# Workaround, pending https://github.com/aio-libs/multidict/issues/11
# headers = request.headers.copy()
headers = CIMultiDict((str(k), v) for k, v in request.headers.items())
if headers.get('Authorization'):
headers['Authorization'] = headers['Authorization'].split()[0] + ' [redacted]'
if headers.get('Cookie'):
Expand Down

0 comments on commit e2cea6c

Please sign in to comment.