diff options
author | Jenkins <jenkins@review.openstack.org> | 2017-08-21 15:15:52 +0000 |
---|---|---|
committer | Gerrit Code Review <review@openstack.org> | 2017-08-21 15:15:52 +0000 |
commit | dfc1e5fa75196dcec563863b403eec386c0e95a6 (patch) | |
tree | 10ba4efa73043c74848890d782d3cf281b7b1aa8 | |
parent | f6f4fe1d83691a30ed983447f1ae40ad7812189a (diff) | |
parent | 480d60ac856937e1a48c1ed6df3b7d2e59a974dc (diff) | |
download | oslo-middleware-dfc1e5fa75196dcec563863b403eec386c0e95a6.tar.gz |
Merge "Invalid parsing of Forwarded header fixed"
-rw-r--r-- | oslo_middleware/http_proxy_to_wsgi.py | 2 | ||||
-rw-r--r-- | oslo_middleware/tests/test_http_proxy_to_wsgi.py | 12 |
2 files changed, 13 insertions, 1 deletions
diff --git a/oslo_middleware/http_proxy_to_wsgi.py b/oslo_middleware/http_proxy_to_wsgi.py index 4d68bcf..701e5c8 100644 --- a/oslo_middleware/http_proxy_to_wsgi.py +++ b/oslo_middleware/http_proxy_to_wsgi.py @@ -49,7 +49,7 @@ class HTTPProxyToWSGI(base.ConfigurableMiddleware): entry = {} for d in proxy.split(";"): key, _, value = d.partition("=") - entry[key.lower()] = value + entry[key.lower().strip()] = value.strip() result.append(entry) return result diff --git a/oslo_middleware/tests/test_http_proxy_to_wsgi.py b/oslo_middleware/tests/test_http_proxy_to_wsgi.py index d114ad7..7fe9a2a 100644 --- a/oslo_middleware/tests/test_http_proxy_to_wsgi.py +++ b/oslo_middleware/tests/test_http_proxy_to_wsgi.py @@ -89,6 +89,18 @@ class TestHTTPProxyToWSGI(test_base.BaseTestCase): response = self.request.get_response(self.middleware) self.assertEqual(b"https://localhost:80/", response.body) + def test__parse_rfc7239_header(self): + expected_result = [{'for': 'foobar', 'proto': 'https'}, + {'for': 'foobaz', 'proto': 'http'}] + + result = self.middleware._parse_rfc7239_header( + "for=foobar;proto=https, for=foobaz;proto=http") + self.assertEqual(expected_result, result) + + result = self.middleware._parse_rfc7239_header( + "for=foobar; proto=https, for=foobaz; proto=http") + self.assertEqual(expected_result, result) + def test_rfc7239_proto_host(self): self.request.headers['Forwarded'] = ( "for=foobar;proto=https;host=example.com, for=foobaz;proto=http") |