diff options
author | OpenShift Merge Robot <openshift-merge-robot@users.noreply.github.com> | 2020-02-11 22:22:55 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-02-11 22:22:55 +0100 |
commit | 4bdfeed5bf9c467c8ab53b392747ec722505b179 (patch) | |
tree | 967c8cc5a213d2f8dfecdd49b15619c878b624dd /pkg/api/handlers/utils/handler.go | |
parent | d34ce1320cc31327675c501d5de94064c4d79f17 (diff) | |
parent | bdccdd2265340d48a0ba868d8c312fdd3172f1c3 (diff) | |
download | podman-4bdfeed5bf9c467c8ab53b392747ec722505b179.tar.gz podman-4bdfeed5bf9c467c8ab53b392747ec722505b179.tar.bz2 podman-4bdfeed5bf9c467c8ab53b392747ec722505b179.zip |
Merge pull request #5169 from edsantiago/apiv2_pod_status_codes
API v2: pods: fix two incorrect return codes
Diffstat (limited to 'pkg/api/handlers/utils/handler.go')
-rw-r--r-- | pkg/api/handlers/utils/handler.go | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/pkg/api/handlers/utils/handler.go b/pkg/api/handlers/utils/handler.go index 970f93791..44bcc794c 100644 --- a/pkg/api/handlers/utils/handler.go +++ b/pkg/api/handlers/utils/handler.go @@ -23,6 +23,14 @@ func IsLibpodRequest(r *http.Request) bool { // WriteResponse encodes the given value as JSON or string and renders it for http client func WriteResponse(w http.ResponseWriter, code int, value interface{}) { + // RFC2616 explicitly states that the following status codes "MUST NOT + // include a message-body": + switch code { + case http.StatusNoContent, http.StatusNotModified: // 204, 304 + w.WriteHeader(code) + return + } + switch v := value.(type) { case string: w.Header().Set("Content-Type", "text/plain; charset=us-ascii") |