MM-17688 - Updated http timeout for plugin install from URL (#11887)
* Bumped http request timeout for plugin install from URL * Added unit test for timeout higher than 30 seconds. Other minor PR feedback * Fixed spacing
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
11b0a20d7d
Коммит
53f4bf1ec1
@@ -10,6 +10,7 @@ import (
|
||||
"io/ioutil"
|
||||
"net/http"
|
||||
"net/url"
|
||||
"time"
|
||||
|
||||
"github.com/mattermost/mattermost-server/mlog"
|
||||
"github.com/mattermost/mattermost-server/model"
|
||||
@@ -17,6 +18,9 @@ import (
|
||||
|
||||
const (
|
||||
MAXIMUM_PLUGIN_FILE_SIZE = 50 * 1024 * 1024
|
||||
// INSTALL_PLUGIN_FROM_URL_HTTP_REQUEST_TIMEOUT defines a high timeout for installing plugins
|
||||
// from an external URL to avoid slow connections or large plugins from failing to install.
|
||||
INSTALL_PLUGIN_FROM_URL_HTTP_REQUEST_TIMEOUT = 60 * time.Minute
|
||||
)
|
||||
|
||||
func (api *API) InitPlugin() {
|
||||
@@ -115,6 +119,8 @@ func installPluginFromUrl(c *Context, w http.ResponseWriter, r *http.Request) {
|
||||
}
|
||||
|
||||
client := c.App.HTTPService.MakeClient(true)
|
||||
client.Timeout = INSTALL_PLUGIN_FROM_URL_HTTP_REQUEST_TIMEOUT
|
||||
|
||||
resp, err := client.Get(downloadUrl)
|
||||
if err != nil {
|
||||
c.Err = model.NewAppError("installPluginFromUrl", "api.plugin.install.download_failed.app_error", nil, err.Error(), http.StatusBadRequest)
|
||||
|
||||
Ссылка в новой задаче
Block a user