@@ -103,20 +103,16 @@ func (r dockerFetcher) open(ctx context.Context, u, mediatype string, offset int
103103 // really distinguish between a 206 and a 200. In the case of 200, we
104104 // can discard the bytes, hiding the seek behavior from the
105105 // implementation.
106-
107106 defer resp .Body .Close ()
107+
108108 if resp .StatusCode == http .StatusNotFound {
109109 return nil , errors .Wrapf (errdefs .ErrNotFound , "content at %v not found" , u )
110110 }
111- body , err := ioutil .ReadAll (resp .Body )
112- if err == nil {
113- dockerErr := errcode.Errors {}
114- err := json .Unmarshal (body , & dockerErr )
115- if err == nil && dockerErr .Len () > 0 {
116- return nil , errors .Errorf ("unexpected status code %v: %s - Server message: %s" , u , resp .Status , dockerErr .Error ())
117- }
111+ var registryErr errcode.Errors
112+ if err := json .NewDecoder (resp .Body ).Decode (& registryErr ); err != nil || registryErr .Len () < 1 {
113+ return nil , errors .Errorf ("unexpected status code %v: %v" , u , resp .Status )
118114 }
119- return nil , errors .Errorf ("unexpected status code %v: %v " , u , resp .Status )
115+ return nil , errors .Errorf ("unexpected status code %v: %s - Server message: %s " , u , resp .Status , registryErr . Error () )
120116 }
121117 if offset > 0 {
122118 cr := resp .Header .Get ("content-range" )
0 commit comments