X-Git-Url: https://git.arvados.org/arvados.git/blobdiff_plain/034d8c6cf7a261d29373233d9302aebe2a2f895a..f4181d5241fed56bda4c552bced7f1afabd24e0e:/lib/controller/federation.go diff --git a/lib/controller/federation.go b/lib/controller/federation.go index 1a0b78be2b..fcff05c003 100644 --- a/lib/controller/federation.go +++ b/lib/controller/federation.go @@ -11,13 +11,14 @@ import ( "fmt" "io" "io/ioutil" + "mime" "net/http" "net/url" "regexp" "strings" - "git.curoverse.com/arvados.git/sdk/go/arvados" - "git.curoverse.com/arvados.git/sdk/go/auth" + "git.arvados.org/arvados.git/sdk/go/arvados" + "git.arvados.org/arvados.git/sdk/go/auth" "github.com/jmcvetta/randutil" ) @@ -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