summary refs log tree commit diff
path: root/synapse/http
diff options
context:
space:
mode:
authorPatrick Cloke <clokep@users.noreply.github.com>2023-04-03 13:20:32 -0400
committerGitHub <noreply@github.com>2023-04-03 13:20:32 -0400
commitcf2f2934ad6c94a269e750684d1d8170b1173b7a (patch)
treef4a42a6834a7570504c8fe83d2cc77ca2bbb379c /synapse/http
parentExperimental Unix socket support (#15353) (diff)
downloadsynapse-cf2f2934ad6c94a269e750684d1d8170b1173b7a.tar.xz
Call appservices on modern paths, falling back to legacy paths. (#15317)
This uses the specced /_matrix/app/v1/... paths instead of the
"legacy" paths. If the homeserver receives an error it will retry
using the legacy path.
Diffstat (limited to 'synapse/http')
-rw-r--r--synapse/http/client.py13
1 files changed, 7 insertions, 6 deletions
diff --git a/synapse/http/client.py b/synapse/http/client.py
index 5ee55981d9..b5cf8123ce 100644
--- a/synapse/http/client.py
+++ b/synapse/http/client.py
@@ -982,20 +982,21 @@ def is_unknown_endpoint(
     """
     if synapse_error is None:
         synapse_error = e.to_synapse_error()
-    # MSC3743 specifies that servers should return a 404 or 405 with an errcode
+
+    # Matrix v1.6 specifies that servers should return a 404 or 405 with an errcode
     # of M_UNRECOGNIZED when they receive a request to an unknown endpoint or
     # to an unknown method, respectively.
     #
-    # Older versions of servers don't properly handle this. This needs to be
-    # rather specific as some endpoints truly do return 404 errors.
+    # Older versions of servers don't return proper errors, so be graceful. But,
+    # also handle that some endpoints truly do return 404 errors.
     return (
         # 404 is an unknown endpoint, 405 is a known endpoint, but unknown method.
         (e.code == 404 or e.code == 405)
         and (
-            # Older Dendrites returned a text body or empty body.
-            # Older Conduit returned an empty body.
+            # Consider empty body or non-JSON bodies to be unrecognised (matches
+            # older Dendrites & Conduits).
             not e.response
-            or e.response == b"404 page not found"
+            or not e.response.startswith(b"{")
             # The proper response JSON with M_UNRECOGNIZED errcode.
             or synapse_error.errcode == Codes.UNRECOGNIZED
         )