forked from MirrorHub/synapse
Remove unused OPTIONS handlers. (#8621)
The handling of OPTIONS requests was consolidated in #7534, but the endpoint specific handlers were not removed.
This commit is contained in:
parent
b19b63e6b4
commit
514a240aed
14 changed files with 2 additions and 64 deletions
1
changelog.d/8621.misc
Normal file
1
changelog.d/8621.misc
Normal file
|
@ -0,0 +1 @@
|
|||
Remove unused OPTIONS handlers.
|
|
@ -272,7 +272,6 @@ class RestServlet:
|
|||
on_PUT
|
||||
on_POST
|
||||
on_DELETE
|
||||
on_OPTIONS
|
||||
|
||||
Automatically handles turning CodeMessageExceptions thrown by these methods
|
||||
into the appropriate HTTP response.
|
||||
|
@ -283,7 +282,7 @@ class RestServlet:
|
|||
if hasattr(self, "PATTERNS"):
|
||||
patterns = self.PATTERNS
|
||||
|
||||
for method in ("GET", "PUT", "POST", "OPTIONS", "DELETE"):
|
||||
for method in ("GET", "PUT", "POST", "DELETE"):
|
||||
if hasattr(self, "on_%s" % (method,)):
|
||||
servlet_classname = self.__class__.__name__
|
||||
method_handler = getattr(self, "on_%s" % (method,))
|
||||
|
|
|
@ -67,9 +67,6 @@ class EventStreamRestServlet(RestServlet):
|
|||
|
||||
return 200, chunk
|
||||
|
||||
def on_OPTIONS(self, request):
|
||||
return 200, {}
|
||||
|
||||
|
||||
class EventRestServlet(RestServlet):
|
||||
PATTERNS = client_patterns("/events/(?P<event_id>[^/]*)$", v1=True)
|
||||
|
|
|
@ -114,9 +114,6 @@ class LoginRestServlet(RestServlet):
|
|||
|
||||
return 200, {"flows": flows}
|
||||
|
||||
def on_OPTIONS(self, request: SynapseRequest):
|
||||
return 200, {}
|
||||
|
||||
async def on_POST(self, request: SynapseRequest):
|
||||
self._address_ratelimiter.ratelimit(request.getClientIP())
|
||||
|
||||
|
|
|
@ -30,9 +30,6 @@ class LogoutRestServlet(RestServlet):
|
|||
self._auth_handler = hs.get_auth_handler()
|
||||
self._device_handler = hs.get_device_handler()
|
||||
|
||||
def on_OPTIONS(self, request):
|
||||
return 200, {}
|
||||
|
||||
async def on_POST(self, request):
|
||||
requester = await self.auth.get_user_by_req(request, allow_expired=True)
|
||||
|
||||
|
@ -58,9 +55,6 @@ class LogoutAllRestServlet(RestServlet):
|
|||
self._auth_handler = hs.get_auth_handler()
|
||||
self._device_handler = hs.get_device_handler()
|
||||
|
||||
def on_OPTIONS(self, request):
|
||||
return 200, {}
|
||||
|
||||
async def on_POST(self, request):
|
||||
requester = await self.auth.get_user_by_req(request, allow_expired=True)
|
||||
user_id = requester.user.to_string()
|
||||
|
|
|
@ -86,9 +86,6 @@ class PresenceStatusRestServlet(RestServlet):
|
|||
|
||||
return 200, {}
|
||||
|
||||
def on_OPTIONS(self, request):
|
||||
return 200, {}
|
||||
|
||||
|
||||
def register_servlets(hs, http_server):
|
||||
PresenceStatusRestServlet(hs).register(http_server)
|
||||
|
|
|
@ -67,9 +67,6 @@ class ProfileDisplaynameRestServlet(RestServlet):
|
|||
|
||||
return 200, {}
|
||||
|
||||
def on_OPTIONS(self, request, user_id):
|
||||
return 200, {}
|
||||
|
||||
|
||||
class ProfileAvatarURLRestServlet(RestServlet):
|
||||
PATTERNS = client_patterns("/profile/(?P<user_id>[^/]*)/avatar_url", v1=True)
|
||||
|
@ -118,9 +115,6 @@ class ProfileAvatarURLRestServlet(RestServlet):
|
|||
|
||||
return 200, {}
|
||||
|
||||
def on_OPTIONS(self, request, user_id):
|
||||
return 200, {}
|
||||
|
||||
|
||||
class ProfileRestServlet(RestServlet):
|
||||
PATTERNS = client_patterns("/profile/(?P<user_id>[^/]*)", v1=True)
|
||||
|
|
|
@ -155,9 +155,6 @@ class PushRuleRestServlet(RestServlet):
|
|||
else:
|
||||
raise UnrecognizedRequestError()
|
||||
|
||||
def on_OPTIONS(self, request, path):
|
||||
return 200, {}
|
||||
|
||||
def notify_user(self, user_id):
|
||||
stream_id = self.store.get_max_push_rules_stream_id()
|
||||
self.notifier.on_new_event("push_rules_key", stream_id, users=[user_id])
|
||||
|
|
|
@ -60,9 +60,6 @@ class PushersRestServlet(RestServlet):
|
|||
|
||||
return 200, {"pushers": filtered_pushers}
|
||||
|
||||
def on_OPTIONS(self, _):
|
||||
return 200, {}
|
||||
|
||||
|
||||
class PushersSetRestServlet(RestServlet):
|
||||
PATTERNS = client_patterns("/pushers/set$", v1=True)
|
||||
|
@ -140,9 +137,6 @@ class PushersSetRestServlet(RestServlet):
|
|||
|
||||
return 200, {}
|
||||
|
||||
def on_OPTIONS(self, _):
|
||||
return 200, {}
|
||||
|
||||
|
||||
class PushersRemoveRestServlet(RestServlet):
|
||||
"""
|
||||
|
@ -182,9 +176,6 @@ class PushersRemoveRestServlet(RestServlet):
|
|||
)
|
||||
return None
|
||||
|
||||
def on_OPTIONS(self, _):
|
||||
return 200, {}
|
||||
|
||||
|
||||
def register_servlets(hs, http_server):
|
||||
PushersRestServlet(hs).register(http_server)
|
||||
|
|
|
@ -72,20 +72,6 @@ class RoomCreateRestServlet(TransactionRestServlet):
|
|||
def register(self, http_server):
|
||||
PATTERNS = "/createRoom"
|
||||
register_txn_path(self, PATTERNS, http_server)
|
||||
# define CORS for all of /rooms in RoomCreateRestServlet for simplicity
|
||||
http_server.register_paths(
|
||||
"OPTIONS",
|
||||
client_patterns("/rooms(?:/.*)?$", v1=True),
|
||||
self.on_OPTIONS,
|
||||
self.__class__.__name__,
|
||||
)
|
||||
# define CORS for /createRoom[/txnid]
|
||||
http_server.register_paths(
|
||||
"OPTIONS",
|
||||
client_patterns("/createRoom(?:/.*)?$", v1=True),
|
||||
self.on_OPTIONS,
|
||||
self.__class__.__name__,
|
||||
)
|
||||
|
||||
def on_PUT(self, request, txn_id):
|
||||
set_tag("txn_id", txn_id)
|
||||
|
@ -104,9 +90,6 @@ class RoomCreateRestServlet(TransactionRestServlet):
|
|||
user_supplied_config = parse_json_object_from_request(request)
|
||||
return user_supplied_config
|
||||
|
||||
def on_OPTIONS(self, request):
|
||||
return 200, {}
|
||||
|
||||
|
||||
# TODO: Needs unit testing for generic events
|
||||
class RoomStateEventRestServlet(TransactionRestServlet):
|
||||
|
|
|
@ -69,9 +69,6 @@ class VoipRestServlet(RestServlet):
|
|||
},
|
||||
)
|
||||
|
||||
def on_OPTIONS(self, request):
|
||||
return 200, {}
|
||||
|
||||
|
||||
def register_servlets(hs, http_server):
|
||||
VoipRestServlet(hs).register(http_server)
|
||||
|
|
|
@ -268,9 +268,6 @@ class PasswordRestServlet(RestServlet):
|
|||
|
||||
return 200, {}
|
||||
|
||||
def on_OPTIONS(self, _):
|
||||
return 200, {}
|
||||
|
||||
|
||||
class DeactivateAccountRestServlet(RestServlet):
|
||||
PATTERNS = client_patterns("/account/deactivate$")
|
||||
|
|
|
@ -176,9 +176,6 @@ class AuthRestServlet(RestServlet):
|
|||
respond_with_html(request, 200, html)
|
||||
return None
|
||||
|
||||
def on_OPTIONS(self, _):
|
||||
return 200, {}
|
||||
|
||||
|
||||
def register_servlets(hs, http_server):
|
||||
AuthRestServlet(hs).register(http_server)
|
||||
|
|
|
@ -642,9 +642,6 @@ class RegisterRestServlet(RestServlet):
|
|||
|
||||
return 200, return_dict
|
||||
|
||||
def on_OPTIONS(self, _):
|
||||
return 200, {}
|
||||
|
||||
async def _do_appservice_registration(self, username, as_token, body):
|
||||
user_id = await self.registration_handler.appservice_register(
|
||||
username, as_token
|
||||
|
|
Loading…
Reference in a new issue