mirror of
https://git.anonymousland.org/anonymousland/synapse.git
synced 2025-05-02 22:14:55 -04:00
Return 200 OK for all OPTIONS requests (#7534)
This commit is contained in:
parent
1531b214fc
commit
4429764c9f
5 changed files with 85 additions and 11 deletions
|
@ -350,9 +350,6 @@ class JsonResource(HttpServer, resource.Resource):
|
|||
register_paths, so will return (possibly via Deferred) either
|
||||
None, or a tuple of (http code, response body).
|
||||
"""
|
||||
if request.method == b"OPTIONS":
|
||||
return _options_handler, "options_request_handler", {}
|
||||
|
||||
request_path = request.path.decode("ascii")
|
||||
|
||||
# Loop through all the registered callbacks to check if the method
|
||||
|
@ -448,6 +445,26 @@ class RootRedirect(resource.Resource):
|
|||
return resource.Resource.getChild(self, name, request)
|
||||
|
||||
|
||||
class OptionsResource(resource.Resource):
|
||||
"""Responds to OPTION requests for itself and all children."""
|
||||
|
||||
def render_OPTIONS(self, request):
|
||||
code, response_json_object = _options_handler(request)
|
||||
|
||||
return respond_with_json(
|
||||
request, code, response_json_object, send_cors=False, canonical_json=False,
|
||||
)
|
||||
|
||||
def getChildWithDefault(self, path, request):
|
||||
if request.method == b"OPTIONS":
|
||||
return self # select ourselves as the child to render
|
||||
return resource.Resource.getChildWithDefault(self, path, request)
|
||||
|
||||
|
||||
class RootOptionsRedirectResource(OptionsResource, RootRedirect):
|
||||
pass
|
||||
|
||||
|
||||
def respond_with_json(
|
||||
request,
|
||||
code,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue