Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

HTTP 304 (NotModified) is not an error! #5176

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 3 additions & 5 deletions pkg/api/handlers/containers.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,9 @@ func StopContainer(w http.ResponseWriter, r *http.Request) {
utils.InternalServerError(w, errors.Wrapf(err, "unable to get state for Container %s", name))
return
}
// If the Container is stopped already, send a 302
// If the Container is stopped already, send a 304
if state == define.ContainerStateStopped || state == define.ContainerStateExited {
utils.Error(w, http.StatusText(http.StatusNotModified), http.StatusNotModified,
errors.Errorf("Container %s is already stopped ", name))
utils.WriteResponse(w, http.StatusNotModified, "")
return
}

Expand Down Expand Up @@ -134,8 +133,7 @@ func StartContainer(w http.ResponseWriter, r *http.Request) {
return
}
if state == define.ContainerStateRunning {
msg := fmt.Sprintf("Container %s is already running", name)
utils.Error(w, msg, http.StatusNotModified, errors.New(msg))
utils.WriteResponse(w, http.StatusNotModified, "")
return
}
if err := con.Start(r.Context(), false); err != nil {
Expand Down
6 changes: 2 additions & 4 deletions pkg/api/handlers/libpod/pods.go
Original file line number Diff line number Diff line change
Expand Up @@ -202,8 +202,7 @@ func PodStop(w http.ResponseWriter, r *http.Request) {
}
}
if allContainersStopped {
alreadyStopped := errors.Errorf("pod %s is already stopped", pod.ID())
utils.Error(w, "Something went wrong", http.StatusNotModified, alreadyStopped)
utils.WriteResponse(w, http.StatusNotModified, "")
return
}

Expand Down Expand Up @@ -249,8 +248,7 @@ func PodStart(w http.ResponseWriter, r *http.Request) {
}
}
if allContainersRunning {
alreadyRunning := errors.Errorf("pod %s is already running", pod.ID())
utils.Error(w, "Something went wrong", http.StatusNotModified, alreadyRunning)
utils.WriteResponse(w, http.StatusNotModified, "")
return
}
if _, err := pod.Start(r.Context()); err != nil {
Expand Down