diff options
author | Patrick Cloke <clokep@users.noreply.github.com> | 2020-07-24 07:08:07 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-07-24 07:08:07 -0400 |
commit | 6a080ea184844f6ee9412a8d6170eb7ff2e5dd56 (patch) | |
tree | 33c4a914278d28a57f95180ee3c09a8e26375b34 /synapse/http | |
parent | Downgrade warning on client disconnect to INFO (#7928) (diff) | |
download | synapse-6a080ea184844f6ee9412a8d6170eb7ff2e5dd56.tar.xz |
Return an empty body for OPTIONS requests. (#7886)
Diffstat (limited to 'synapse/http')
-rw-r--r-- | synapse/http/server.py | 24 |
1 files changed, 5 insertions, 19 deletions
diff --git a/synapse/http/server.py b/synapse/http/server.py index 8e003689c4..d4f9ad6e67 100644 --- a/synapse/http/server.py +++ b/synapse/http/server.py @@ -442,21 +442,6 @@ class StaticResource(File): return super().render_GET(request) -def _options_handler(request): - """Request handler for OPTIONS requests - - This is a request handler suitable for return from - _get_handler_for_request. It returns a 200 and an empty body. - - Args: - request (twisted.web.http.Request): - - Returns: - Tuple[int, dict]: http code, response body. - """ - return 200, {} - - def _unrecognised_request_handler(request): """Request handler for unrecognised requests @@ -490,11 +475,12 @@ 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) + request.setResponseCode(204) + request.setHeader(b"Content-Length", b"0") - return respond_with_json( - request, code, response_json_object, send_cors=True, canonical_json=False, - ) + set_cors_headers(request) + + return b"" def getChildWithDefault(self, path, request): if request.method == b"OPTIONS": |