mirror of https://github.com/docker/docs.git
Make version check return 400 instead of 404
Closes: #13321 Signed-off-by: Doug Davis <dug@us.ibm.com>
This commit is contained in:
parent
29595fd944
commit
7fcf849749
|
@ -1426,7 +1426,7 @@ func makeHttpHandler(logging bool, localMethod string, localRoute string, handle
|
||||||
}
|
}
|
||||||
|
|
||||||
if version.GreaterThan(api.APIVERSION) {
|
if version.GreaterThan(api.APIVERSION) {
|
||||||
http.Error(w, fmt.Errorf("client and server don't have same version (client API version: %s, server API version: %s)", version, api.APIVERSION).Error(), http.StatusNotFound)
|
http.Error(w, fmt.Errorf("client and server don't have same version (client API version: %s, server API version: %s)", version, api.APIVERSION).Error(), http.StatusBadRequest)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -46,6 +46,11 @@ You can still call an old version of the API using
|
||||||
|
|
||||||
### What's new
|
### What's new
|
||||||
|
|
||||||
|
**New!**
|
||||||
|
When the daemon detects a version mismatch with the client, usually when
|
||||||
|
the client is newer than the daemon, an HTTP 400 is now returned instead
|
||||||
|
of a 404.
|
||||||
|
|
||||||
`GET /containers/(id)/stats`
|
`GET /containers/(id)/stats`
|
||||||
|
|
||||||
**New!**
|
**New!**
|
||||||
|
|
|
@ -13,6 +13,8 @@ page_keywords: API, Docker, rcli, REST, documentation
|
||||||
- The API tends to be REST, but for some complex commands, like `attach`
|
- The API tends to be REST, but for some complex commands, like `attach`
|
||||||
or `pull`, the HTTP connection is hijacked to transport `STDOUT`,
|
or `pull`, the HTTP connection is hijacked to transport `STDOUT`,
|
||||||
`STDIN` and `STDERR`.
|
`STDIN` and `STDERR`.
|
||||||
|
- When the client API version is newer than the daemon's an HTTP
|
||||||
|
`400 Bad Request` error message is returned.
|
||||||
|
|
||||||
# 2. Endpoints
|
# 2. Endpoints
|
||||||
|
|
||||||
|
|
|
@ -2,6 +2,8 @@ package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"net/http"
|
"net/http"
|
||||||
|
"net/http/httputil"
|
||||||
|
"time"
|
||||||
|
|
||||||
"github.com/go-check/check"
|
"github.com/go-check/check"
|
||||||
)
|
)
|
||||||
|
@ -23,3 +25,18 @@ func (s *DockerSuite) TestApiGetEnabledCors(c *check.C) {
|
||||||
//c.Assert(res.Header.Get("Access-Control-Allow-Origin"), check.Equals, "*")
|
//c.Assert(res.Header.Get("Access-Control-Allow-Origin"), check.Equals, "*")
|
||||||
//c.Assert(res.Header.Get("Access-Control-Allow-Headers"), check.Equals, "Origin, X-Requested-With, Content-Type, Accept, X-Registry-Auth")
|
//c.Assert(res.Header.Get("Access-Control-Allow-Headers"), check.Equals, "Origin, X-Requested-With, Content-Type, Accept, X-Registry-Auth")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (s *DockerSuite) TestVersionStatusCode(c *check.C) {
|
||||||
|
conn, err := sockConn(time.Duration(10 * time.Second))
|
||||||
|
c.Assert(err, check.IsNil)
|
||||||
|
|
||||||
|
client := httputil.NewClientConn(conn, nil)
|
||||||
|
defer client.Close()
|
||||||
|
|
||||||
|
req, err := http.NewRequest("GET", "/v999.0/version", nil)
|
||||||
|
c.Assert(err, check.IsNil)
|
||||||
|
req.Header.Set("User-Agent", "Docker-Client/999.0")
|
||||||
|
|
||||||
|
res, err := client.Do(req)
|
||||||
|
c.Assert(res.StatusCode, check.Equals, http.StatusBadRequest)
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue