diff options
-rw-r--r-- | .mailmap | 1 | ||||
-rw-r--r-- | keystone/common/wsgi.py | 3 | ||||
-rw-r--r-- | tests/test_wsgi.py | 11 |
3 files changed, 14 insertions, 1 deletions
@@ -21,3 +21,4 @@ Sirish Bitra <sirish.bitra@gmail.com> sirish.bitra <sirish.bitra@gmail.com> Sirish Bitra <sirish.bitra@gmail.com> sirishbitra <sirish.bitra@gmail.com> Sirish Bitra <sirish.bitra@gmail.com> root <root@bsirish.(none)> Zhongyue Luo <zhongyue.nah@intel.com> <lzyeval@gmail.com> +Chmouel Boudjnah <chmouel@enovance.com> <chmouel@chmouel.com> diff --git a/keystone/common/wsgi.py b/keystone/common/wsgi.py index a07ae1172..d5368b2a2 100644 --- a/keystone/common/wsgi.py +++ b/keystone/common/wsgi.py @@ -161,9 +161,10 @@ class Application(BaseApplication): del arg_dict['controller'] LOG.debug(_('arg_dict: %s'), arg_dict) - # allow middleware up the stack to provide context & params + # allow middleware up the stack to provide context, params and headers. context = req.environ.get(CONTEXT_ENV, {}) context['query_string'] = dict(req.params.iteritems()) + context['headers'] = dict(req.headers.iteritems()) context['path'] = req.environ['PATH_INFO'] params = req.environ.get(PARAMS_ENV, {}) if 'REMOTE_USER' in req.environ: diff --git a/tests/test_wsgi.py b/tests/test_wsgi.py index 2d81ba86b..0cd6a7337 100644 --- a/tests/test_wsgi.py +++ b/tests/test_wsgi.py @@ -84,6 +84,17 @@ class ApplicationTest(BaseWSGITest): resp = req.get_response(FakeApp()) self.assertEqual(jsonutils.loads(resp.body), {'1': '2'}) + def test_headers_available(self): + class FakeApp(wsgi.Application): + def index(self, context): + return context['headers'] + + app = FakeApp() + req = self._make_request(url='/?1=2') + req.headers['X-Foo'] = "bar" + resp = req.get_response(app) + self.assertIn('X-Foo', eval(resp.body)) + def test_render_response(self): data = {'attribute': 'value'} body = '{"attribute": "value"}' |