Skip to content

Commit

Permalink
Fix redirect in redirect blob
Browse files Browse the repository at this point in the history
  • Loading branch information
wzshiming committed Jul 9, 2024
1 parent 31e111b commit 1da762c
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions crproxy_blob.go
Original file line number Diff line number Diff line change
Expand Up @@ -192,11 +192,18 @@ func (c *CRProxy) redirectBlobResponse(rw http.ResponseWriter, r *http.Request,
}()

switch resp.StatusCode {
default:
if c.logger != nil {
c.logger.Println("failed to redirect blob", info.Host, info.Image, resp.StatusCode)
}
errcode.ServeJSON(rw, errcode.ErrorCodeUnavailable)
return
case http.StatusUnauthorized, http.StatusForbidden:
errcode.ServeJSON(rw, errcode.ErrorCodeDenied)
return
default:
errcode.ServeJSON(rw, errcode.ErrorCodeUnavailable)
case http.StatusTemporaryRedirect, http.StatusPermanentRedirect, http.StatusMovedPermanently, http.StatusFound:
location := resp.Header.Get("Location")
http.Redirect(rw, r, location, http.StatusFound)
return
case http.StatusOK:
v := GetCtxValue(r.Context())
Expand Down

0 comments on commit 1da762c

Please sign in to comment.