From 8266c381d62a0790c489e27cc93ed8f4618d03c7 Mon Sep 17 00:00:00 2001 From: Michael Crosby Date: Fri, 1 Aug 2014 15:59:19 -0700 Subject: [PATCH] Check content type along with content length Docker-DCO-1.1-Signed-off-by: Michael Crosby (github: crosbymichael) --- api/server/server.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/api/server/server.go b/api/server/server.go index b01ce0d0d1..858dd4e4d6 100644 --- a/api/server/server.go +++ b/api/server/server.go @@ -724,15 +724,16 @@ func postContainersStart(eng *engine.Engine, version version.Version, w http.Res ) // allow a nil body for backwards compatibility - if r.Body != nil { + if r.Body != nil && r.ContentLength > 0 { if !api.MatchesContentType(r.Header.Get("Content-Type"), "application/json") { - return fmt.Errorf("Content-Type is not supported: %s", r.Header.Get("Content-Type")) + return fmt.Errorf("Content-Type of application/json is required") } if err := job.DecodeEnv(r.Body); err != nil { return err } } + if err := job.Run(); err != nil { if err.Error() == "Container already started" { w.WriteHeader(http.StatusNotModified)