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:
Sebastiaan van Stijn
2025-11-14 23:43:40 +01:00
parent a81d441133
commit 20d65620f9
2 changed files with 0 additions and 6 deletions

View File

@@ -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
}