Skip to content

Commit

Permalink
Merge pull request #13156 from flouthoc/fix-compat-build-response-header
Browse files Browse the repository at this point in the history
compat: endpoint `/build` must set header `content type` as `application/json` in response header.
  • Loading branch information
openshift-merge-robot authored Feb 7, 2022
2 parents 30b076b + 3b561a4 commit 46d9a25
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
2 changes: 1 addition & 1 deletion pkg/api/handlers/compat/images_build.go
Original file line number Diff line number Diff line change
Expand Up @@ -605,8 +605,8 @@ func BuildImage(w http.ResponseWriter, r *http.Request) {
}

// Send headers and prime client for stream to come
w.WriteHeader(http.StatusOK)
w.Header().Set("Content-Type", "application/json")
w.WriteHeader(http.StatusOK)
flush()

body := w.(io.Writer)
Expand Down
5 changes: 5 additions & 0 deletions test/apiv2/10-images.at
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,11 @@ t POST "libpod/build?dockerfile=containerfile" $CONTAINERFILE_TAR application/js
t POST "build?dockerfile=containerfile" $CONTAINERFILE_TAR application/json 200 \
.stream~"STEP 1/1: FROM $IMAGE"

# Build api response header must contain Content-type: application/json
t POST "build?dockerfile=containerfile" $CONTAINERFILE_TAR application/json 200
response_headers=$(cat "$WORKDIR/curl.headers.out")
like "$response_headers" ".*application/json.*" "header does not contains application/json"

# PR #12091: output from compat API must now include {"aux":{"ID":"sha..."}}
t POST "build?dockerfile=containerfile" $CONTAINERFILE_TAR 200 \
'.aux|select(has("ID")).ID~^sha256:[0-9a-f]\{64\}$'
Expand Down

0 comments on commit 46d9a25

Please sign in to comment.