mirror of
https://github.com/moby/moby.git
synced 2026-01-11 18:51:37 +00:00
client: Client.buildRequest: don't set content-header if not set
This function was setting `text/plain` as default content-type for any
request that had a non-nil body.
However, this would also set the content-type if (e.g.) `http.NoBody` was set,
or if an empty reader was used, which would result in the daemon potentialy
rejecting the request, as it validates request to be using `application/json`;
d9ee22d1ab/daemon/server/httputils/httputils.go (L47-L58)
=== RUN TestCommitInheritsEnv
commit_test.go:30: assertion failed: error is not nil: Error response from daemon: unsupported Content-Type header (text/plain): must be 'application/json'
--- FAIL: TestCommitInheritsEnv (0.02s)
This patch removes setting the default content-type.
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This commit is contained in:
@@ -110,9 +110,6 @@ func (cli *Client) buildRequest(ctx context.Context, method, path string, body i
|
||||
req.Host = DummyHost
|
||||
}
|
||||
|
||||
if body != nil && req.Header.Get("Content-Type") == "" {
|
||||
req.Header.Set("Content-Type", "text/plain")
|
||||
}
|
||||
return req, nil
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user