API v1.21 (Docker Engine v1.9.0) enforces the request to have a JSON
content-type on exec start (see 45dc57f22931e6cb8ad522602da8aa985bddcfab).
An exception was added in 0b5e628e14a673cd1940876b2f3d091c2fe236d9 to
make this check conditional (supporting API < 1.21).
API v1.23 and older are deprecated, and this patch removes the feature.
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
| ... | ... |
@@ -71,15 +71,6 @@ func (s *containerRouter) postContainerExecStart(ctx context.Context, w http.Res |
| 71 | 71 |
return err |
| 72 | 72 |
} |
| 73 | 73 |
|
| 74 |
- version := httputils.VersionFromContext(ctx) |
|
| 75 |
- if versions.LessThan(version, "1.22") {
|
|
| 76 |
- // API versions before 1.22 did not enforce application/json content-type. |
|
| 77 |
- // Allow older clients to work by patching the content-type. |
|
| 78 |
- if r.Header.Get("Content-Type") != "application/json" {
|
|
| 79 |
- r.Header.Set("Content-Type", "application/json")
|
|
| 80 |
- } |
|
| 81 |
- } |
|
| 82 |
- |
|
| 83 | 74 |
var ( |
| 84 | 75 |
execName = vars["name"] |
| 85 | 76 |
stdin, inStream io.ReadCloser |
| ... | ... |
@@ -96,6 +87,8 @@ func (s *containerRouter) postContainerExecStart(ctx context.Context, w http.Res |
| 96 | 96 |
} |
| 97 | 97 |
|
| 98 | 98 |
if execStartCheck.ConsoleSize != nil {
|
| 99 |
+ version := httputils.VersionFromContext(ctx) |
|
| 100 |
+ |
|
| 99 | 101 |
// Not supported before 1.42 |
| 100 | 102 |
if versions.LessThan(version, "1.42") {
|
| 101 | 103 |
execStartCheck.ConsoleSize = nil |
| ... | ... |
@@ -109,20 +109,6 @@ func (s *DockerAPISuite) TestExecAPIStartEnsureHeaders(c *testing.T) {
|
| 109 | 109 |
assert.Assert(c, resp.Header.Get("Server") != "")
|
| 110 | 110 |
} |
| 111 | 111 |
|
| 112 |
-func (s *DockerAPISuite) TestExecAPIStartBackwardsCompatible(c *testing.T) {
|
|
| 113 |
- testRequires(c, DaemonIsLinux) // Windows only supports 1.25 or later |
|
| 114 |
- runSleepingContainer(c, "-d", "--name", "test") |
|
| 115 |
- id := createExec(c, "test") |
|
| 116 |
- |
|
| 117 |
- resp, body, err := request.Post(testutil.GetContext(c), fmt.Sprintf("/v1.20/exec/%s/start", id), request.RawString(`{"Detach": true}`), request.ContentType("text/plain"))
|
|
| 118 |
- assert.NilError(c, err) |
|
| 119 |
- |
|
| 120 |
- b, err := request.ReadBody(body) |
|
| 121 |
- comment := fmt.Sprintf("response body: %s", b)
|
|
| 122 |
- assert.NilError(c, err, comment) |
|
| 123 |
- assert.Equal(c, resp.StatusCode, http.StatusOK, comment) |
|
| 124 |
-} |
|
| 125 |
- |
|
| 126 | 112 |
// #19362 |
| 127 | 113 |
func (s *DockerAPISuite) TestExecAPIStartMultipleTimesError(c *testing.T) {
|
| 128 | 114 |
runSleepingContainer(c, "-d", "--name", "test") |