diff --git a/api/server/router/container/exec.go b/api/server/router/container/exec.go index 619355a50a..b62342af85 100644 --- a/api/server/router/container/exec.go +++ b/api/server/router/container/exec.go @@ -71,15 +71,6 @@ func (s *containerRouter) postContainerExecStart(ctx context.Context, w http.Res return err } - version := httputils.VersionFromContext(ctx) - if versions.LessThan(version, "1.22") { - // API versions before 1.22 did not enforce application/json content-type. - // Allow older clients to work by patching the content-type. - if r.Header.Get("Content-Type") != "application/json" { - r.Header.Set("Content-Type", "application/json") - } - } - var ( execName = vars["name"] stdin, inStream io.ReadCloser @@ -96,6 +87,8 @@ func (s *containerRouter) postContainerExecStart(ctx context.Context, w http.Res } if execStartCheck.ConsoleSize != nil { + version := httputils.VersionFromContext(ctx) + // Not supported before 1.42 if versions.LessThan(version, "1.42") { execStartCheck.ConsoleSize = nil diff --git a/integration-cli/docker_api_exec_test.go b/integration-cli/docker_api_exec_test.go index f9612fc667..612ef292b1 100644 --- a/integration-cli/docker_api_exec_test.go +++ b/integration-cli/docker_api_exec_test.go @@ -109,20 +109,6 @@ func (s *DockerAPISuite) TestExecAPIStartEnsureHeaders(c *testing.T) { assert.Assert(c, resp.Header.Get("Server") != "") } -func (s *DockerAPISuite) TestExecAPIStartBackwardsCompatible(c *testing.T) { - testRequires(c, DaemonIsLinux) // Windows only supports 1.25 or later - runSleepingContainer(c, "-d", "--name", "test") - id := createExec(c, "test") - - resp, body, err := request.Post(testutil.GetContext(c), fmt.Sprintf("/v1.20/exec/%s/start", id), request.RawString(`{"Detach": true}`), request.ContentType("text/plain")) - assert.NilError(c, err) - - b, err := request.ReadBody(body) - comment := fmt.Sprintf("response body: %s", b) - assert.NilError(c, err, comment) - assert.Equal(c, resp.StatusCode, http.StatusOK, comment) -} - // #19362 func (s *DockerAPISuite) TestExecAPIStartMultipleTimesError(c *testing.T) { runSleepingContainer(c, "-d", "--name", "test")