Skip to content

Commit f30567e

Browse files
Merge pull request #26898 from andershausding/fix_missing_content_type_header
fix: Correct order of setting up header fields for endpoint responses
2 parents b6d92f7 + 8566ef7 commit f30567e

File tree

7 files changed

+7
-7
lines changed

7 files changed

+7
-7
lines changed

pkg/api/handlers/compat/images_push.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,8 +120,8 @@ func PushImage(w http.ResponseWriter, r *http.Request) {
120120
statusWritten := false
121121
writeStatusCode := func(code int) {
122122
if !statusWritten {
123-
w.WriteHeader(code)
124123
w.Header().Set("Content-Type", "application/json")
124+
w.WriteHeader(code)
125125
flush()
126126
statusWritten = true
127127
}

pkg/api/handlers/libpod/containers_stats.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,8 +76,8 @@ func StatsContainer(w http.ResponseWriter, r *http.Request) {
7676
return
7777
}
7878
// Write header and content type.
79-
w.WriteHeader(http.StatusOK)
8079
w.Header().Set("Content-Type", "application/json")
80+
w.WriteHeader(http.StatusOK)
8181
wroteContent = true
8282
}
8383

pkg/api/handlers/libpod/images.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -597,8 +597,8 @@ func CommitContainer(w http.ResponseWriter, r *http.Request) {
597597
statusWritten := false
598598
writeStatusCode := func(code int) {
599599
if !statusWritten {
600-
w.WriteHeader(code)
601600
w.Header().Set("Content-Type", "application/json")
601+
w.WriteHeader(code)
602602
flush()
603603
statusWritten = true
604604
}

pkg/api/handlers/libpod/images_pull.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,8 +152,8 @@ func ImagesPull(w http.ResponseWriter, r *http.Request) {
152152
}
153153
}
154154

155-
w.WriteHeader(http.StatusOK)
156155
w.Header().Set("Content-Type", "application/json")
156+
w.WriteHeader(http.StatusOK)
157157
flush()
158158

159159
enc := json.NewEncoder(w)

pkg/api/handlers/libpod/images_push.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,8 +138,8 @@ func PushImage(w http.ResponseWriter, r *http.Request) {
138138
}
139139
}
140140

141-
w.WriteHeader(http.StatusOK)
142141
w.Header().Set("Content-Type", "application/json")
142+
w.WriteHeader(http.StatusOK)
143143
flush()
144144

145145
enc := json.NewEncoder(w)

pkg/api/handlers/libpod/manifests.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -451,8 +451,8 @@ func ManifestPush(w http.ResponseWriter, r *http.Request) {
451451
}
452452
}
453453

454-
w.WriteHeader(http.StatusOK)
455454
w.Header().Set("Content-Type", "application/json")
455+
w.WriteHeader(http.StatusOK)
456456
flush()
457457

458458
enc := json.NewEncoder(w)

pkg/api/handlers/utils/images.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,8 +146,8 @@ func CompatPull(ctx context.Context, w http.ResponseWriter, runtime *libpod.Runt
146146
statusWritten := false
147147
writeStatusCode := func(code int) {
148148
if !statusWritten {
149-
w.WriteHeader(code)
150149
w.Header().Set("Content-Type", "application/json")
150+
w.WriteHeader(code)
151151
flush()
152152
statusWritten = true
153153
}

0 commit comments

Comments
 (0)