1
0
mirror of https://github.com/docker/cli.git synced 2026-01-15 07:40:57 +03:00

Merge pull request #14850 from runcom/14846-fix-get-images-search-content-type

Fix wrong Content-Type returned by /images/search API
Upstream-commit: 5328cc346f56beae2f5a230d445ebdc5b784e6c1
Component: engine
This commit is contained in:
Doug Davis
2015-07-22 06:16:16 -07:00
2 changed files with 12 additions and 1 deletions

View File

@@ -818,7 +818,7 @@ func (s *Server) getImagesSearch(version version.Version, w http.ResponseWriter,
if err != nil {
return err
}
return json.NewEncoder(w).Encode(query.Results)
return writeJSON(w, http.StatusOK, query.Results)
}
func (s *Server) postImagesPush(version version.Version, w http.ResponseWriter, r *http.Request, vars map[string]string) error {

View File

@@ -120,3 +120,14 @@ func (s *DockerSuite) TestApiImagesHistory(c *check.C) {
c.Assert(len(historydata), check.Not(check.Equals), 0)
c.Assert(historydata[0].Tags[0], check.Equals, "test-api-images-history:latest")
}
// #14846
func (s *DockerSuite) TestApiImagesSearchJSONContentType(c *check.C) {
testRequires(c, Network)
res, b, err := sockRequestRaw("GET", "/images/search?term=test", nil, "application/json")
b.Close()
c.Assert(err, check.IsNil)
c.Assert(res.StatusCode, check.Equals, http.StatusOK)
c.Assert(res.Header.Get("Content-Type"), check.Equals, "application/json")
}