X-Git-Url: https://git.arvados.org/arvados.git/blobdiff_plain/ee5443faad325b16047b9ad4cd588baf51e231fa..2b8061c14002b9c58ccebbfbccd041398eb5201c:/lib/controller/router/request.go diff --git a/lib/controller/router/request.go b/lib/controller/router/request.go index 31f2e1d7ba..97efe31726 100644 --- a/lib/controller/router/request.go +++ b/lib/controller/router/request.go @@ -61,7 +61,19 @@ func guessAndParse(k, v string) (interface{}, error) { // If the request has a parameter whose name is attrsKey (e.g., // "collection"), it is renamed to "attrs". func (rtr *router) loadRequestParams(req *http.Request, attrsKey string) (map[string]interface{}, error) { + // Here we call ParseForm and ParseMultipartForm explicitly + // (even though ParseMultipartForm calls ParseForm if + // necessary) to ensure we catch errors encountered in + // ParseForm. In the non-multipart-form case, + // ParseMultipartForm returns ErrNotMultipart and hides the + // ParseForm error. err := req.ParseForm() + if err == nil { + err = req.ParseMultipartForm(int64(rtr.config.MaxRequestSize)) + if err == http.ErrNotMultipart { + err = nil + } + } if err != nil { if err.Error() == "http: request body too large" { return nil, httpError(http.StatusRequestEntityTooLarge, err)