From f092982329c11932a5a9a4beabb32b5f1e5665f6 Mon Sep 17 00:00:00 2001 From: Travis Ralston Date: Fri, 3 May 2024 11:17:32 -0600 Subject: [PATCH 1/2] Finish 405 responses to avoid hanging --- sync3/handler/handler.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/sync3/handler/handler.go b/sync3/handler/handler.go index 9ab0db77..c73a7a10 100644 --- a/sync3/handler/handler.go +++ b/sync3/handler/handler.go @@ -185,7 +185,11 @@ func (h *SyncLiveHandler) addPrometheusMetrics() { func (h *SyncLiveHandler) ServeHTTP(w http.ResponseWriter, req *http.Request) { if req.Method != "POST" { + w.Header().Add("Content-Type", "application/json") w.WriteHeader(http.StatusMethodNotAllowed) + // This is a standard error response. + // See M_UNRECOGNIZED in https://spec.matrix.org/v1.10/client-server-api/#common-error-codes + w.Write([]byte("{\"errcode\":\"M_UNRECOGNIZED\",\"error\":\"Wrong request method\"}")) return } err := h.serve(w, req) From 5ba006e2174938c9d16f683148465405785f314e Mon Sep 17 00:00:00 2001 From: Travis Ralston Date: Fri, 3 May 2024 11:32:49 -0600 Subject: [PATCH 2/2] Try closing the request body specifically too --- sync3/handler/handler.go | 1 + 1 file changed, 1 insertion(+) diff --git a/sync3/handler/handler.go b/sync3/handler/handler.go index c73a7a10..d3b5bb89 100644 --- a/sync3/handler/handler.go +++ b/sync3/handler/handler.go @@ -185,6 +185,7 @@ func (h *SyncLiveHandler) addPrometheusMetrics() { func (h *SyncLiveHandler) ServeHTTP(w http.ResponseWriter, req *http.Request) { if req.Method != "POST" { + defer req.Body.Close() w.Header().Add("Content-Type", "application/json") w.WriteHeader(http.StatusMethodNotAllowed) // This is a standard error response.