docker/docker — pull request #8324 by cpuguy83 (2014-10-01 02:12:55+00:00)
Title: Fix #6231 - Accept chunked encoding on start

Fixed using the @sfitts solution

I have a test for this, not commited since I can't seem to make go do the chunked encoding on the request, as such it passes no matter what.

Confirmed this fixes the issue manually.

```go
func TestConstainersStartChunkedEncodingHostConifg(t *testing.T) {
eng := NewTestEngine(t)
defer mkDaemonFromEngine(eng, t).Nuke()

r := httptest.NewRecorder()

var testData engine.Env
testData.Set("Image", "docker-test-image")
testData.SetAuto("Volumes", map[string]struct{}{"/foo": struct{}{}})
testData.Set("Cmd", "true")
jsonData := bytes.NewBuffer(nil)
if err := testData.Encode(jsonData); err != nil {
t.Fatal(err)
}

req, err := http.NewRequest("POST", "/containers/create?name=chunk_test", jsonData)
if err != nil {
t.Fatal(err)
}

req.Header.Add("Content-Type", "application/json")
if err := server.ServeRequest(eng, api.APIVERSION, r, req); err != nil {
t.Fatal(err)
}
assertHttpNotError(r, t)

var testData2 engine.Env
testData2.SetAuto("Binds", []string{"/tmp:/foo"})
jsonData = bytes.NewBuffer(nil)
if err := testData2.Encode(jsonData); err != nil {
t.Fatal(err)
}

req, err = http.NewRequest("POST", "/containers/chunk_test/start", jsonData)
if err != nil {
t.Fatal(err)
}

req.Header.Add("Content-Type", "application/json")
req.Header.Add("Transfer-Encoding", "chunked")
if err := server.ServeRequest(eng, api.APIVERSION, r, req); err != nil {
t.Fatal(err)
}
assertHttpNotError(r, t)

type config struct {
HostConfig struct {
Binds []string
}
}

req, err = http.NewRequest("GET", "/containers/chunk_test/json", nil)
if err != nil {
t.Fatal(err)
}

r2 := httptest.NewRecorder()
req.Header.Add("Content-Type", "application/json")
if err := server.ServeRequest(eng, api.APIVERSION, r2, req); err != nil {
t.Fatal(err)
}
assertHttpNotError(r, t)

c := config{}

json.Unmarshal(r2.Body.Bytes(), &c)

if c.HostConfig.Binds[0] != "/tmp:/foo" {
t.Fatal("Chunked encoding not properly handled, execpted binds to be /tmp:/foo, got:", c.HostConfig.Binds[0])
}
}
```