Serve blobs when a storage driver supports redirects but are disabled
Fixes issue where an error was returned instead of serving the blob Signed-off-by: Brian Bland <brian.bland@docker.com>
This commit is contained in:
parent
13b56c9d20
commit
cf4fdc1be0
1 changed files with 33 additions and 33 deletions
|
@ -34,18 +34,22 @@ func (bs *blobServer) ServeBlob(ctx context.Context, w http.ResponseWriter, r *h
|
|||
return err
|
||||
}
|
||||
|
||||
if bs.redirect {
|
||||
redirectURL, err := bs.driver.URLFor(ctx, path, map[string]interface{}{"method": r.Method})
|
||||
|
||||
switch err.(type) {
|
||||
case nil:
|
||||
if bs.redirect {
|
||||
// Redirect to storage URL.
|
||||
http.Redirect(w, r, redirectURL, http.StatusTemporaryRedirect)
|
||||
return err
|
||||
}
|
||||
|
||||
case driver.ErrUnsupportedMethod:
|
||||
// Fallback to serving the content directly.
|
||||
default:
|
||||
// Some unexpected error.
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
br, err := newFileReader(ctx, bs.driver, path, desc.Size)
|
||||
if err != nil {
|
||||
return err
|
||||
|
@ -72,7 +76,3 @@ func (bs *blobServer) ServeBlob(ctx context.Context, w http.ResponseWriter, r *h
|
|||
http.ServeContent(w, r, desc.Digest.String(), time.Time{}, br)
|
||||
return nil
|
||||
}
|
||||
|
||||
// Some unexpected error.
|
||||
return err
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue