Better RFC support for OPTIONS and CORS preflight requests
Ensures that the Allow header is set for 405 responses from the proxy, as per RFC 2616. CORS preflight requests now require both the Origin and Access- Control-Request-Method headers to get a successful (200) response. The draft spec defines errors as a response with a non-200 status code. This patch sets the CORS error response code to 401 (Not Authorized). A later patch may choose to make this configurable. There is some ambiguity between RFC 2616 and the CORS draft spec around what to do when a CORS request is made but the cluster has no CORS information about the requested resource. This patch chooses to return an error in this case because it is what would be simplest for CORS client apps. Further improvements to the OPTIONS verb not included in this patch include support of more top-level resources (eg / or /v1/) or sending the configured constraints in the reponse body. Change-Id: I40be059e8bbf3737dafc4e6fefa7598d05669c60
This commit is contained in:
@@ -213,7 +213,9 @@ class Application(object):
|
||||
handler = getattr(controller, req.method)
|
||||
getattr(handler, 'publicly_accessible')
|
||||
except AttributeError:
|
||||
return HTTPMethodNotAllowed(request=req)
|
||||
allowed_methods = getattr(controller, 'allowed_methods', set())
|
||||
return HTTPMethodNotAllowed(
|
||||
request=req, headers={'Allow': ', '.join(allowed_methods)})
|
||||
if path_parts['version']:
|
||||
req.path_info_pop()
|
||||
if 'swift.authorize' in req.environ:
|
||||
|
||||
Reference in New Issue
Block a user