Skip to content

Commit 2f27632

Browse files
committed
Return application/json for image/load API (quite=1)
This fix tries to address the issue raised in 25529 wehre the image/load API returns `application/json` for quiet=0 and `text/plain` for quite=1. This fix makes the change so that `application/json` is returned for both quiet=0 and quite=1. This fix has been tested manually. This fix fixes 25529. Signed-off-by: Yong Tang <[email protected]>
1 parent eb28dde commit 2f27632

2 files changed

Lines changed: 7 additions & 10 deletions

File tree

api/server/router/image/image_routes.go

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -201,17 +201,14 @@ func (s *imageRouter) postImagesLoad(ctx context.Context, w http.ResponseWriter,
201201
}
202202
quiet := httputils.BoolValueOrDefault(r, "quiet", true)
203203

204-
if !quiet {
205-
w.Header().Set("Content-Type", "application/json")
204+
w.Header().Set("Content-Type", "application/json")
206205

207-
output := ioutils.NewWriteFlusher(w)
208-
defer output.Close()
209-
if err := s.backend.LoadImage(r.Body, output, quiet); err != nil {
210-
output.Write(streamformatter.NewJSONStreamFormatter().FormatError(err))
211-
}
212-
return nil
206+
output := ioutils.NewWriteFlusher(w)
207+
defer output.Close()
208+
if err := s.backend.LoadImage(r.Body, output, quiet); err != nil {
209+
output.Write(streamformatter.NewJSONStreamFormatter().FormatError(err))
213210
}
214-
return s.backend.LoadImage(r.Body, w, quiet)
211+
return nil
215212
}
216213

217214
func (s *imageRouter) deleteImages(ctx context.Context, w http.ResponseWriter, r *http.Request, vars map[string]string) error {

image/tarexport/load.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,8 @@ func (l *tarexporter) Load(inTar io.ReadCloser, outStream io.Writer, quiet bool)
3030
)
3131
if !quiet {
3232
progressOutput = sf.NewProgressOutput(outStream, false)
33-
outStream = &streamformatter.StdoutFormatter{Writer: outStream, StreamFormatter: streamformatter.NewJSONStreamFormatter()}
3433
}
34+
outStream = &streamformatter.StdoutFormatter{Writer: outStream, StreamFormatter: streamformatter.NewJSONStreamFormatter()}
3535

3636
tmpDir, err := ioutil.TempDir("", "docker-import-")
3737
if err != nil {

0 commit comments

Comments
 (0)