From a1656dffa98fbc8865e476b214e4e0c562547d39 Mon Sep 17 00:00:00 2001 From: Jesse Hallam Date: Mon, 14 May 2018 13:24:22 -0400 Subject: MM-10201: querystring for get slash commands (#8779) * pass GET slash command payloads through query string Previously, both GET and POST requests received the payload via the body, but this was incorrect for GET requests. Now, the payloads for GET requests is sent via the query string. * reorder tests for clarity * switch command tests to use httptest servers * restore original test command endpoints --- app/command.go | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'app/command.go') diff --git a/app/command.go b/app/command.go index 796d656a7..92c35865a 100644 --- a/app/command.go +++ b/app/command.go @@ -230,12 +230,14 @@ func (a *App) ExecuteCommand(args *model.CommandArgs) (*model.CommandResponse, * p.Set("response_url", args.SiteURL+"/hooks/commands/"+hook.Id) } - method := "POST" + var req *http.Request if cmd.Method == model.COMMAND_METHOD_GET { - method = "GET" + req, _ = http.NewRequest(http.MethodGet, cmd.URL, nil) + req.URL.RawQuery = p.Encode() + } else { + req, _ = http.NewRequest(http.MethodPost, cmd.URL, strings.NewReader(p.Encode())) } - req, _ := http.NewRequest(method, cmd.URL, strings.NewReader(p.Encode())) req.Header.Set("Accept", "application/json") req.Header.Set("Authorization", "Token "+cmd.Token) if cmd.Method == model.COMMAND_METHOD_POST { -- cgit v1.2.3-1-g7c22