From e8a5448b0767026925b5ad396f6de1be79ac2325 Mon Sep 17 00:00:00 2001 From: Tim Burke Date: Tue, 15 Nov 2016 14:35:42 -0800 Subject: [PATCH] Add X-Openstack-Request-Id to Access-Control-Expose-Headers Change-Id: Ib95a693042f0b3cf204033eb5957660cb3573dcf Related-Change: I56cd4738808b99c0a08463f83c100be51a62db05 --- api-ref/source/parameters.yaml | 3 ++- doc/source/cors.rst | 3 ++- swift/proxy/controllers/base.py | 2 +- test/unit/proxy/test_server.py | 26 +++++++++++++------------- 4 files changed, 18 insertions(+), 16 deletions(-) diff --git a/api-ref/source/parameters.yaml b/api-ref/source/parameters.yaml index 97ee990368..8140c9fff9 100644 --- a/api-ref/source/parameters.yaml +++ b/api-ref/source/parameters.yaml @@ -398,7 +398,8 @@ X-Container-Meta-Access-Control-Expose-Headers: - All “simple response headers” as listed on `http://www.w3.org/TR/cors/#simple-response-header `_. - - The headers ``etag``, ``x-timestamp``, ``x-trans-id``. + - The headers ``etag``, ``x-timestamp``, ``x-trans-id``, + ``x-openstack-request-id``. - All metadata headers (``X-Container-Meta-*`` for containers and ``X-Object-Meta-*`` for objects). - headers listed in ``X-Container-Meta-Access-Control-Expose-Headers``. diff --git a/doc/source/cors.rst b/doc/source/cors.rst index 3dc07d3e3a..e8b07819d8 100644 --- a/doc/source/cors.rst +++ b/doc/source/cors.rst @@ -43,7 +43,8 @@ returns the following values for this header, * "simple response headers" as listed on http://www.w3.org/TR/cors/#simple-response-header -* the headers ``etag``, ``x-timestamp``, ``x-trans-id`` +* the headers ``etag``, ``x-timestamp``, ``x-trans-id``, + ``x-openstack-request-id`` * all metadata headers (``X-Container-Meta-*`` for containers and ``X-Object-Meta-*`` for objects) * headers listed in ``X-Container-Meta-Access-Control-Expose-Headers`` diff --git a/swift/proxy/controllers/base.py b/swift/proxy/controllers/base.py index c5e8ebd08f..be98bc15dd 100644 --- a/swift/proxy/controllers/base.py +++ b/swift/proxy/controllers/base.py @@ -239,7 +239,7 @@ def cors_validation(func): expose_headers = set([ 'cache-control', 'content-language', 'content-type', 'expires', 'last-modified', 'pragma', 'etag', - 'x-timestamp', 'x-trans-id']) + 'x-timestamp', 'x-trans-id', 'x-openstack-request-id']) for header in resp.headers: if header.startswith('X-Container-Meta') or \ header.startswith('X-Object-Meta'): diff --git a/test/unit/proxy/test_server.py b/test/unit/proxy/test_server.py index 290086205e..393d007da3 100644 --- a/test/unit/proxy/test_server.py +++ b/test/unit/proxy/test_server.py @@ -5221,11 +5221,11 @@ class TestObjectController(unittest.TestCase): exposed = set( h.strip() for h in resp.headers['access-control-expose-headers'].split(',')) - expected_exposed = set(['cache-control', 'content-language', - 'content-type', 'expires', 'last-modified', - 'pragma', 'etag', 'x-timestamp', - 'x-trans-id', 'x-object-meta-color', - 'x-object-meta-color-ex']) + expected_exposed = set([ + 'cache-control', 'content-language', 'content-type', 'expires', + 'last-modified', 'pragma', 'etag', 'x-timestamp', 'x-trans-id', + 'x-openstack-request-id', 'x-object-meta-color', + 'x-object-meta-color-ex']) self.assertEqual(expected_exposed, exposed) # test allow_origin * @@ -5272,10 +5272,10 @@ class TestObjectController(unittest.TestCase): exposed = set( h.strip() for h in resp.headers['access-control-expose-headers'].split(',')) - expected_exposed = set(['cache-control', 'content-language', - 'content-type', 'expires', 'last-modified', - 'pragma', 'etag', 'x-timestamp', - 'x-trans-id', 'x-object-meta-color']) + expected_exposed = set([ + 'cache-control', 'content-language', 'content-type', 'expires', + 'last-modified', 'pragma', 'etag', 'x-timestamp', 'x-trans-id', + 'x-openstack-request-id', 'x-object-meta-color']) self.assertEqual(expected_exposed, exposed) # test allow_origin empty @@ -7534,10 +7534,10 @@ class TestContainerController(unittest.TestCase): exposed = set( h.strip() for h in resp.headers['access-control-expose-headers'].split(',')) - expected_exposed = set(['cache-control', 'content-language', - 'content-type', 'expires', 'last-modified', - 'pragma', 'etag', 'x-timestamp', - 'x-trans-id', 'x-container-meta-color']) + expected_exposed = set([ + 'cache-control', 'content-language', 'content-type', 'expires', + 'last-modified', 'pragma', 'etag', 'x-timestamp', 'x-trans-id', + 'x-openstack-request-id', 'x-container-meta-color']) self.assertEqual(expected_exposed, exposed) def _gather_x_account_headers(self, controller_call, req, *connect_args,