Merge pull request #2128 from weaveworks/issues/2109-skip-empty-json
Don't attempt to parse JSON payload if it is 0 bytes long. Fixes #2109.
This commit is contained in:
commit
28e0b14220
2 files changed
+6
-1
No files matched your search
@@ -15,7 +15,7 @@ func (i *startContainerInterceptor) InterceptRequest(r *http.Request) error {
|
|||||||
|
|
||||||
// If the client has sent some JSON which might be a HostConfig, add our
|
// If the client has sent some JSON which might be a HostConfig, add our
|
||||||
// parameters back into it, otherwise Docker will consider them overwritten
|
// parameters back into it, otherwise Docker will consider them overwritten
|
||||||
if containerShouldAttach(container) && r.Header.Get("Content-Type") == "application/json" {
|
if containerShouldAttach(container) && r.Header.Get("Content-Type") == "application/json" && r.ContentLength > 0 {
|
||||||
params := map[string]interface{}{}
|
params := map[string]interface{}{}
|
||||||
if err := unmarshalRequestBody(r, ¶ms); err != nil {
|
if err := unmarshalRequestBody(r, ¶ms); err != nil {
|
||||||
return err
|
return err
|
||||||
|
|||||||
@@ -33,6 +33,11 @@ proxy docker_on $HOST1 create --name=c4 --memory-swap -1 $SMALL_IMAGE echo foo
|
|||||||
assert_raises "proxy docker_api_on $HOST1 POST /containers/c4/start 'null'"
|
assert_raises "proxy docker_api_on $HOST1 POST /containers/c4/start 'null'"
|
||||||
assert "docker_on $HOST1 inspect -f '{{.HostConfig.MemorySwap}}' c4" "-1"
|
assert "docker_on $HOST1 inspect -f '{{.HostConfig.MemorySwap}}' c4" "-1"
|
||||||
|
|
||||||
|
# Start c4b with an empty HostConfig (generated by Docker 1.11.0-rc2)
|
||||||
|
proxy docker_on $HOST1 create --name=c4b --memory-swap -1 $SMALL_IMAGE echo foo
|
||||||
|
assert_raises "proxy docker_api_on $HOST1 POST /containers/c4b/start ''"
|
||||||
|
assert "docker_on $HOST1 inspect -f '{{.HostConfig.MemorySwap}}' c4b" "-1"
|
||||||
|
|
||||||
# Start c6 with both named and unnamed HostConfig
|
# Start c6 with both named and unnamed HostConfig
|
||||||
proxy docker_on $HOST1 create --name=c6 $SMALL_IMAGE $CHECK_ETHWE_UP
|
proxy docker_on $HOST1 create --name=c6 $SMALL_IMAGE $CHECK_ETHWE_UP
|
||||||
proxy docker_api_on $HOST1 POST /containers/c6/start '{"NetworkMode": "container:c2", "HostConfig": {"NetworkMode": "container:c1"}}'
|
proxy docker_api_on $HOST1 POST /containers/c6/start '{"NetworkMode": "container:c2", "HostConfig": {"NetworkMode": "container:c1"}}'
|
||||||
|
|||||||
Reference in new issue
Block a user