Leave remote HEAD routing to the generic HEAD fix
ci/woodpecker/pr/pre-commit Pipeline was successful
ci/woodpecker/pr/test Pipeline was successful
ci/woodpecker/pr/build Pipeline was successful

This commit is contained in:
2026-10-17 12:43:01 +11:00
parent 3b69b58ba3
commit a7aa37982a
+1 -14
View File
@@ -45,7 +45,6 @@ func NewProxyHandler(engine *proxy.Engine, virtualEngine *virtual.Engine, db *da
func (h *ProxyHandler) Routes() chi.Router {
r := chi.NewRouter()
r.Get("/remote/{remoteName}/*", h.handleProxy)
r.Head("/remote/{remoteName}/*", h.handleProxyHead)
r.Get("/local/{localName}/*", h.handleLocal)
r.Get("/virtual/{virtualName}/*", h.handleVirtual)
return r
@@ -112,7 +111,7 @@ func (h *ProxyHandler) handleProxy(w http.ResponseWriter, r *http.Request) {
defer result.Reader.Close()
var body io.Reader = result.Reader
if sr, ok := serveRewriter(prov, path); ok {
if sr, ok := prov.(provider.ServeRewriter); ok && prov.Classify(path) == provider.Mutable {
raw, ok := rewriteServed(w, r, sr, *remote, result.Reader)
if !ok {
return
@@ -145,13 +144,6 @@ func (h *ProxyHandler) handleProxyHead(w http.ResponseWriter, r *http.Request) {
return
}
// Rewritten bodies differ in size from the cached object, so HEAD takes the
// GET path; net/http discards the body for HEAD.
if _, ok := serveRewriter(prov, path); ok {
h.handleProxy(w, r)
return
}
result, err := h.engine.Head(r.Context(), *remote, path, prov)
if err != nil {
var proxyErr *proxy.ProxyError
@@ -288,11 +280,6 @@ func rewriteServed(w http.ResponseWriter, r *http.Request, sr provider.ServeRewr
return raw, true
}
func serveRewriter(prov provider.Provider, path string) (provider.ServeRewriter, bool) {
sr, ok := prov.(provider.ServeRewriter)
return sr, ok && prov.Classify(path) == provider.Mutable
}
// validHost accepts host[:port] where host is a DNS name or IP literal.
func validHost(hostport string) bool {
host, port := hostport, ""