diff --git a/sync3/handler/handler.go b/sync3/handler/handler.go index 9ab0db77..d3b5bb89 100644 --- a/sync3/handler/handler.go +++ b/sync3/handler/handler.go @@ -185,7 +185,12 @@ 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. + // 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)