/images/search was replying with Content-Type text/plain instead
of application/json.
Fix #14846
Signed-off-by: Antonio Murdaca <runcom@linux.com>
| ... | ... |
@@ -818,7 +818,7 @@ func (s *Server) getImagesSearch(version version.Version, w http.ResponseWriter, |
| 818 | 818 |
if err != nil {
|
| 819 | 819 |
return err |
| 820 | 820 |
} |
| 821 |
- return json.NewEncoder(w).Encode(query.Results) |
|
| 821 |
+ return writeJSON(w, http.StatusOK, query.Results) |
|
| 822 | 822 |
} |
| 823 | 823 |
|
| 824 | 824 |
func (s *Server) postImagesPush(version version.Version, w http.ResponseWriter, r *http.Request, vars map[string]string) error {
|
| ... | ... |
@@ -120,3 +120,14 @@ func (s *DockerSuite) TestApiImagesHistory(c *check.C) {
|
| 120 | 120 |
c.Assert(len(historydata), check.Not(check.Equals), 0) |
| 121 | 121 |
c.Assert(historydata[0].Tags[0], check.Equals, "test-api-images-history:latest") |
| 122 | 122 |
} |
| 123 |
+ |
|
| 124 |
+// #14846 |
|
| 125 |
+func (s *DockerSuite) TestApiImagesSearchJSONContentType(c *check.C) {
|
|
| 126 |
+ testRequires(c, Network) |
|
| 127 |
+ |
|
| 128 |
+ res, b, err := sockRequestRaw("GET", "/images/search?term=test", nil, "application/json")
|
|
| 129 |
+ b.Close() |
|
| 130 |
+ c.Assert(err, check.IsNil) |
|
| 131 |
+ c.Assert(res.StatusCode, check.Equals, http.StatusOK) |
|
| 132 |
+ c.Assert(res.Header.Get("Content-Type"), check.Equals, "application/json")
|
|
| 133 |
+} |