X-Git-Url: https://git.arvados.org/arvados.git/blobdiff_plain/66d07bb91f91b0cd4c92c7ffa913f7181a3d4942..3911cd836c4e937262d48f9b0af703a9d7d68cdd:/lib/controller/federation.go 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