mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
Check content type along with content length
Docker-DCO-1.1-Signed-off-by: Michael Crosby <michael@docker.com> (github: crosbymichael)
This commit is contained in:
parent
78ac75fe00
commit
8266c381d6
1 changed files with 3 additions and 2 deletions
|
@ -724,15 +724,16 @@ func postContainersStart(eng *engine.Engine, version version.Version, w http.Res
|
||||||
)
|
)
|
||||||
|
|
||||||
// allow a nil body for backwards compatibility
|
// 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") {
|
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 {
|
if err := job.DecodeEnv(r.Body); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := job.Run(); err != nil {
|
if err := job.Run(); err != nil {
|
||||||
if err.Error() == "Container already started" {
|
if err.Error() == "Container already started" {
|
||||||
w.WriteHeader(http.StatusNotModified)
|
w.WriteHeader(http.StatusNotModified)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue