From 54979214ca3f1894faffdeebda182b45997ad4f9 Mon Sep 17 00:00:00 2001 From: Mark Haines Date: Wed, 23 Aug 2017 14:43:54 +0100 Subject: [PATCH] Use NotJSON instead of BadJSON when the JSON couldn't be decoded --- .../matrix-org/dendrite/federationapi/writers/invite.go | 2 +- .../matrix-org/dendrite/federationapi/writers/send.go | 7 ++++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/src/github.com/matrix-org/dendrite/federationapi/writers/invite.go b/src/github.com/matrix-org/dendrite/federationapi/writers/invite.go index d4073ec7a..dc89f4a75 100644 --- a/src/github.com/matrix-org/dendrite/federationapi/writers/invite.go +++ b/src/github.com/matrix-org/dendrite/federationapi/writers/invite.go @@ -34,7 +34,7 @@ func Invite( if err := json.Unmarshal(request.Content(), &event); err != nil { return util.JSONResponse{ Code: 400, - JSON: jsonerror.BadJSON("The request body could not be decoded into valid JSON. " + err.Error()), + JSON: jsonerror.NotJSON("The request body could not be decoded into valid JSON. " + err.Error()), } } diff --git a/src/github.com/matrix-org/dendrite/federationapi/writers/send.go b/src/github.com/matrix-org/dendrite/federationapi/writers/send.go index 67ee6b027..ddae07555 100644 --- a/src/github.com/matrix-org/dendrite/federationapi/writers/send.go +++ b/src/github.com/matrix-org/dendrite/federationapi/writers/send.go @@ -3,6 +3,9 @@ package writers import ( "encoding/json" "fmt" + "net/http" + "time" + "github.com/matrix-org/dendrite/clientapi/httputil" "github.com/matrix-org/dendrite/clientapi/jsonerror" "github.com/matrix-org/dendrite/clientapi/producers" @@ -10,8 +13,6 @@ import ( "github.com/matrix-org/dendrite/roomserver/api" "github.com/matrix-org/gomatrixserverlib" "github.com/matrix-org/util" - "net/http" - "time" ) // Send implements /_matrix/federation/v1/send/{txnID} @@ -39,7 +40,7 @@ func Send( if err := json.Unmarshal(request.Content(), &t); err != nil { return util.JSONResponse{ Code: 400, - JSON: jsonerror.BadJSON("The request body could not be decoded into valid JSON. " + err.Error()), + JSON: jsonerror.NotJSON("The request body could not be decoded into valid JSON. " + err.Error()), } }