X-Git-Url: https://git.arvados.org/arvados.git/blobdiff_plain/7c2aa951ed9e7d0010fd58d59dc1e98c9d5e2800..3c0e4dc35b5f2fc34e050fef304cdec0cebe51ae:/lib/controller/federation.go?ds=sidebyside diff --git a/lib/controller/federation.go b/lib/controller/federation.go index 1a0b78be2b..ed2eb31c78 100644 --- a/lib/controller/federation.go +++ b/lib/controller/federation.go @@ -11,6 +11,7 @@ import ( "fmt" "io" "io/ioutil" + "mime" "net/http" "net/url" "regexp" @@ -61,7 +62,11 @@ func (h *Handler) remoteClusterRequest(remoteID string, req *http.Request) (*htt // downstream proxy steps. func loadParamsFromForm(req *http.Request) error { var postBody *bytes.Buffer - if req.Body != nil && req.Header.Get("Content-Type") == "application/x-www-form-urlencoded" { + if ct := req.Header.Get("Content-Type"); ct == "" { + // Assume application/octet-stream, i.e., no form to parse. + } else if ct, _, err := mime.ParseMediaType(ct); err != nil { + return err + } else if ct == "application/x-www-form-urlencoded" && req.Body != nil { var cl int64 if req.ContentLength > 0 { cl = req.ContentLength @@ -270,7 +275,7 @@ func (h *Handler) saltAuthToken(req *http.Request, remote string) (updatedReq *h } updatedReq.Header.Set("Authorization", "Bearer "+token) - // Remove api_token=... from the the query string, in case we + // Remove api_token=... from the query string, in case we // end up forwarding the request. if values, err := url.ParseQuery(updatedReq.URL.RawQuery); err != nil { return nil, err