19597: Parse multipart/form-data request body.
[arvados.git] / lib / controller / router / request.go
index 39b4c5100608ebf6a14b250ec26185886aed3ad3..c0a2f23cc12c0ed2ddaf2566cb5bc6eff494fbf1 100644 (file)
@@ -62,8 +62,18 @@ func guessAndParse(k, v string) (interface{}, error) {
 // "collection"), it is renamed to "attrs".
 func (rtr *router) loadRequestParams(req *http.Request, attrsKey string) (map[string]interface{}, error) {
        err := req.ParseForm()
+       if err == nil {
+               err = req.ParseMultipartForm(int64(rtr.config.MaxRequestSize))
+               if err == http.ErrNotMultipart {
+                       err = nil
+               }
+       }
        if err != nil {
-               return nil, httpError(http.StatusBadRequest, err)
+               if err.Error() == "http: request body too large" {
+                       return nil, httpError(http.StatusRequestEntityTooLarge, err)
+               } else {
+                       return nil, httpError(http.StatusBadRequest, err)
+               }
        }
        params := map[string]interface{}{}
 
@@ -169,6 +179,10 @@ var boolParams = map[string]bool{
        "include_old_versions":    true,
        "redirect_to_new_user":    true,
        "send_notification_email": true,
+       "bypass_federation":       true,
+       "recursive":               true,
+       "exclude_home_project":    true,
+       "no_forward":              true,
 }
 
 func stringToBool(s string) bool {