Merge pull request #26898 from andershausding/fix_missing_content_type_header

fix: Correct order of setting up header fields for endpoint responses
This commit is contained in:
openshift-merge-bot[bot]
2025-09-08 12:45:03 +00:00
committed by GitHub
7 changed files with 7 additions and 7 deletions

View File

@ -120,8 +120,8 @@ func PushImage(w http.ResponseWriter, r *http.Request) {
statusWritten := false statusWritten := false
writeStatusCode := func(code int) { writeStatusCode := func(code int) {
if !statusWritten { if !statusWritten {
w.WriteHeader(code)
w.Header().Set("Content-Type", "application/json") w.Header().Set("Content-Type", "application/json")
w.WriteHeader(code)
flush() flush()
statusWritten = true statusWritten = true
} }

View File

@ -76,8 +76,8 @@ func StatsContainer(w http.ResponseWriter, r *http.Request) {
return return
} }
// Write header and content type. // Write header and content type.
w.WriteHeader(http.StatusOK)
w.Header().Set("Content-Type", "application/json") w.Header().Set("Content-Type", "application/json")
w.WriteHeader(http.StatusOK)
wroteContent = true wroteContent = true
} }

View File

@ -597,8 +597,8 @@ func CommitContainer(w http.ResponseWriter, r *http.Request) {
statusWritten := false statusWritten := false
writeStatusCode := func(code int) { writeStatusCode := func(code int) {
if !statusWritten { if !statusWritten {
w.WriteHeader(code)
w.Header().Set("Content-Type", "application/json") w.Header().Set("Content-Type", "application/json")
w.WriteHeader(code)
flush() flush()
statusWritten = true statusWritten = true
} }

View File

@ -152,8 +152,8 @@ func ImagesPull(w http.ResponseWriter, r *http.Request) {
} }
} }
w.WriteHeader(http.StatusOK)
w.Header().Set("Content-Type", "application/json") w.Header().Set("Content-Type", "application/json")
w.WriteHeader(http.StatusOK)
flush() flush()
enc := json.NewEncoder(w) enc := json.NewEncoder(w)

View File

@ -138,8 +138,8 @@ func PushImage(w http.ResponseWriter, r *http.Request) {
} }
} }
w.WriteHeader(http.StatusOK)
w.Header().Set("Content-Type", "application/json") w.Header().Set("Content-Type", "application/json")
w.WriteHeader(http.StatusOK)
flush() flush()
enc := json.NewEncoder(w) enc := json.NewEncoder(w)

View File

@ -451,8 +451,8 @@ func ManifestPush(w http.ResponseWriter, r *http.Request) {
} }
} }
w.WriteHeader(http.StatusOK)
w.Header().Set("Content-Type", "application/json") w.Header().Set("Content-Type", "application/json")
w.WriteHeader(http.StatusOK)
flush() flush()
enc := json.NewEncoder(w) enc := json.NewEncoder(w)

View File

@ -146,8 +146,8 @@ func CompatPull(ctx context.Context, w http.ResponseWriter, runtime *libpod.Runt
statusWritten := false statusWritten := false
writeStatusCode := func(code int) { writeStatusCode := func(code int) {
if !statusWritten { if !statusWritten {
w.WriteHeader(code)
w.Header().Set("Content-Type", "application/json") w.Header().Set("Content-Type", "application/json")
w.WriteHeader(code)
flush() flush()
statusWritten = true statusWritten = true
} }