diff options
author | Jenkins <jenkins@review.openstack.org> | 2015-06-22 13:33:29 +0000 |
---|---|---|
committer | Gerrit Code Review <review@openstack.org> | 2015-06-22 13:33:29 +0000 |
commit | af41f0aa06ad430e2a08babfbe3e8d6b5b6f1eec (patch) | |
tree | a1add583b1fb3621d82855c23f167ca0d186b462 | |
parent | 2f78940871237c19256040d23eee03d8b067a589 (diff) | |
parent | afb79f98cfe817e25661fda3b36685e34c8e9543 (diff) | |
download | oslo-middleware-af41f0aa06ad430e2a08babfbe3e8d6b5b6f1eec.tar.gz |
Merge "Use correct oslo_middleware.base methods in CORS middleware."
-rw-r--r-- | oslo_middleware/cors.py | 17 |
1 files changed, 9 insertions, 8 deletions
diff --git a/oslo_middleware/cors.py b/oslo_middleware/cors.py index 3e0021b..513bdbc 100644 --- a/oslo_middleware/cors.py +++ b/oslo_middleware/cors.py @@ -15,6 +15,7 @@ # Default allowed headers import copy import logging + from oslo_config import cfg from oslo_middleware import base import webob.dec @@ -116,19 +117,19 @@ class CORS(base.Middleware): self.allowed_origins[allowed_origin] = conf[section] - @webob.dec.wsgify - def __call__(self, req): - # If it's an OPTIONS request, handle it immediately. Otherwise, - # pass it through to the application. + def process_request(self, req): + '''If we detect an OPTIONS request, handle it immediately.''' if req.method == 'OPTIONS': resp = webob.response.Response(status=webob.exc.HTTPOk.code) self._apply_cors_preflight_headers(request=req, response=resp) - else: - resp = req.get_response(self.application) - self._apply_cors_request_headers(request=req, response=resp) + return resp + + def process_response(self, response, request=None): + '''Detect CORS headers on the request, and decorate the response.''' + self._apply_cors_request_headers(request=request, response=response) # Finally, return the response. - return resp + return response def _split_header_values(self, request, header_name): """Convert a comma-separated header value into a list of values.""" |