mirror of
https://github.com/imjasonh/kontain.me
synced 2026-07-18 23:03:06 +00:00
support HEAD for the rest of them
This commit is contained in:
parent
6d00baaf15
commit
d466ea0402
6 changed files with 128 additions and 7 deletions
|
|
@ -151,6 +151,18 @@ func (s *Storage) ServeIndex(w http.ResponseWriter, r *http.Request, idx v1.Imag
|
|||
return err
|
||||
}
|
||||
|
||||
// If it's just a HEAD request, serve that.
|
||||
if r.Method == http.MethodHead {
|
||||
s, err := idx.Size()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
w.Header().Set("Docker-Content-Digest", digest.String())
|
||||
w.Header().Set("Content-Type", string(mt))
|
||||
w.Header().Set("Content-Length", fmt.Sprintf("%d", s))
|
||||
return nil
|
||||
}
|
||||
|
||||
// Redirect to manifest blob.
|
||||
Blob(w, r, digest.String())
|
||||
return nil
|
||||
|
|
@ -238,6 +250,22 @@ func (s *Storage) ServeManifest(w http.ResponseWriter, r *http.Request, img v1.I
|
|||
return err
|
||||
}
|
||||
|
||||
// If it's just a HEAD request, serve that.
|
||||
if r.Method == http.MethodHead {
|
||||
mt, err := img.MediaType()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
s, err := img.Size()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
w.Header().Set("Docker-Content-Digest", digest.String())
|
||||
w.Header().Set("Content-Type", string(mt))
|
||||
w.Header().Set("Content-Length", fmt.Sprintf("%d", s))
|
||||
return nil
|
||||
}
|
||||
|
||||
// Redirect to manifest blob.
|
||||
Blob(w, r, digest.String())
|
||||
return nil
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue