@@ -5,6 +5,7 @@ package app
5
5
6
6
import (
7
7
"fmt"
8
+ "io"
8
9
"io/ioutil"
9
10
"net/http"
10
11
"net/url"
@@ -253,17 +254,19 @@ func (a *App) ExecuteCommand(args *model.CommandArgs) (*model.CommandResponse, *
253
254
} else {
254
255
defer resp .Body .Close ()
255
256
257
+ body := io .LimitReader (resp .Body , MaxIntegrationResponseSize )
258
+
256
259
if resp .StatusCode == http .StatusOK {
257
- if response , err := model .CommandResponseFromHTTPBody (resp .Header .Get ("Content-Type" ), resp . Body ); err != nil {
260
+ if response , err := model .CommandResponseFromHTTPBody (resp .Header .Get ("Content-Type" ), body ); err != nil {
258
261
return nil , model .NewAppError ("command" , "api.command.execute_command.failed.app_error" , map [string ]interface {}{"Trigger" : trigger }, err .Error (), http .StatusInternalServerError )
259
262
} else if response == nil {
260
263
return nil , model .NewAppError ("command" , "api.command.execute_command.failed_empty.app_error" , map [string ]interface {}{"Trigger" : trigger }, "" , http .StatusInternalServerError )
261
264
} else {
262
265
return a .HandleCommandResponse (cmd , args , response , false )
263
266
}
264
267
} else {
265
- body , _ := ioutil .ReadAll (resp . Body )
266
- return nil , model .NewAppError ("command" , "api.command.execute_command.failed_resp.app_error" , map [string ]interface {}{"Trigger" : trigger , "Status" : resp .Status }, string (body ), http .StatusInternalServerError )
268
+ bodyBytes , _ := ioutil .ReadAll (body )
269
+ return nil , model .NewAppError ("command" , "api.command.execute_command.failed_resp.app_error" , map [string ]interface {}{"Trigger" : trigger , "Status" : resp .Status }, string (bodyBytes ), http .StatusInternalServerError )
267
270
}
268
271
}
269
272
}
0 commit comments