summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJenkins <jenkins@review.openstack.org>2013-06-14 16:15:16 +0000
committerGerrit Code Review <review@openstack.org>2013-06-14 16:15:16 +0000
commit9b08fee9dce4e9c4e9628f0c86ef4c94b1b3f910 (patch)
tree399b6926c5eaf3c89d99a681d364fc690389fb13
parent0e4976f79e8964b42161c13c870908b2e4e90ac5 (diff)
parentce0baf07c0484d7e65b1d93cdd1ec4a1f8fcd60a (diff)
downloadkeystone-9b08fee9dce4e9c4e9628f0c86ef4c94b1b3f910.tar.gz
keystone-9b08fee9dce4e9c4e9628f0c86ef4c94b1b3f910.tar.xz
keystone-9b08fee9dce4e9c4e9628f0c86ef4c94b1b3f910.zip
Merge "Allow request headers access in app context."
-rw-r--r--.mailmap1
-rw-r--r--keystone/common/wsgi.py3
-rw-r--r--tests/test_wsgi.py11
3 files changed, 14 insertions, 1 deletions
diff --git a/.mailmap b/.mailmap
index 737f9738..ae9016a8 100644
--- a/.mailmap
+++ b/.mailmap
@@ -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 a07ae117..d5368b2a 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 2d81ba86..0cd6a733 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"}'