Do not close the connection abruptly on too big file uploads (#9083)
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
e718d2544f
Коммит
b367b1ff40
@@ -4,6 +4,8 @@
|
|||||||
package api4
|
package api4
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"io"
|
||||||
|
"io/ioutil"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
|
||||||
"github.com/mattermost/mattermost-server/model"
|
"github.com/mattermost/mattermost-server/model"
|
||||||
@@ -27,6 +29,8 @@ func getBrandImage(c *Context, w http.ResponseWriter, r *http.Request) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func uploadBrandImage(c *Context, w http.ResponseWriter, r *http.Request) {
|
func uploadBrandImage(c *Context, w http.ResponseWriter, r *http.Request) {
|
||||||
|
defer io.Copy(ioutil.Discard, r.Body)
|
||||||
|
|
||||||
if r.ContentLength > *c.App.Config().FileSettings.MaxFileSize {
|
if r.ContentLength > *c.App.Config().FileSettings.MaxFileSize {
|
||||||
c.Err = model.NewAppError("uploadBrandImage", "api.admin.upload_brand_image.too_large.app_error", nil, "", http.StatusRequestEntityTooLarge)
|
c.Err = model.NewAppError("uploadBrandImage", "api.admin.upload_brand_image.too_large.app_error", nil, "", http.StatusRequestEntityTooLarge)
|
||||||
return
|
return
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ package api4
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"io"
|
"io"
|
||||||
|
"io/ioutil"
|
||||||
"net/http"
|
"net/http"
|
||||||
"net/url"
|
"net/url"
|
||||||
"strconv"
|
"strconv"
|
||||||
@@ -56,6 +57,8 @@ func (api *API) InitFile() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func uploadFile(c *Context, w http.ResponseWriter, r *http.Request) {
|
func uploadFile(c *Context, w http.ResponseWriter, r *http.Request) {
|
||||||
|
defer io.Copy(ioutil.Discard, r.Body)
|
||||||
|
|
||||||
if !*c.App.Config().FileSettings.EnableFileAttachments {
|
if !*c.App.Config().FileSettings.EnableFileAttachments {
|
||||||
c.Err = model.NewAppError("uploadFile", "api.file.attachments.disabled.app_error", nil, "", http.StatusNotImplemented)
|
c.Err = model.NewAppError("uploadFile", "api.file.attachments.disabled.app_error", nil, "", http.StatusNotImplemented)
|
||||||
return
|
return
|
||||||
|
|||||||
@@ -7,6 +7,8 @@ import (
|
|||||||
"bytes"
|
"bytes"
|
||||||
"encoding/base64"
|
"encoding/base64"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"io"
|
||||||
|
"io/ioutil"
|
||||||
"net/http"
|
"net/http"
|
||||||
"strconv"
|
"strconv"
|
||||||
|
|
||||||
@@ -796,6 +798,8 @@ func getTeamIcon(c *Context, w http.ResponseWriter, r *http.Request) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func setTeamIcon(c *Context, w http.ResponseWriter, r *http.Request) {
|
func setTeamIcon(c *Context, w http.ResponseWriter, r *http.Request) {
|
||||||
|
defer io.Copy(ioutil.Discard, r.Body)
|
||||||
|
|
||||||
c.RequireTeamId()
|
c.RequireTeamId()
|
||||||
if c.Err != nil {
|
if c.Err != nil {
|
||||||
return
|
return
|
||||||
|
|||||||
@@ -5,6 +5,8 @@ package api4
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"io"
|
||||||
|
"io/ioutil"
|
||||||
"net/http"
|
"net/http"
|
||||||
"strconv"
|
"strconv"
|
||||||
"time"
|
"time"
|
||||||
@@ -234,6 +236,8 @@ func getProfileImage(c *Context, w http.ResponseWriter, r *http.Request) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func setProfileImage(c *Context, w http.ResponseWriter, r *http.Request) {
|
func setProfileImage(c *Context, w http.ResponseWriter, r *http.Request) {
|
||||||
|
defer io.Copy(ioutil.Discard, r.Body)
|
||||||
|
|
||||||
c.RequireUserId()
|
c.RequireUserId()
|
||||||
if c.Err != nil {
|
if c.Err != nil {
|
||||||
return
|
return
|
||||||
|
|||||||
Ссылка в новой задаче
Block a user