From ccaa7eda3ee392cb11e39c3f733e9e726fc25a09 Mon Sep 17 00:00:00 2001 From: Thomas Steen Rasmussen Date: Wed, 19 Apr 2017 16:19:09 +0200 Subject: [PATCH] fix check for x-forwarded-for header for WS connections --- daphne/utils.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/daphne/utils.py b/daphne/utils.py index cb8043c..1ffa3ee 100644 --- a/daphne/utils.py +++ b/daphne/utils.py @@ -27,6 +27,9 @@ def parse_x_forwarded_for(headers, # Convert twisted-style headers into dicts if isinstance(headers, Headers): headers = dict(headers.getAllRawHeaders()) + else: + # convert non twisted headers dict into utf-8 + headers = {name.encode("utf-8"): values.encode("utf-8") for name, values in headers.items()} # Lowercase all header names in the dict headers = {name.lower(): values for name, values in headers.items()}