fix: HEAD requests fetch and stream the full body #89

Merged
benvin merged 1 commits from benvin/head-metadata-only into master 2026-07-02 22:06:51 +10:00
Owner

Fixes #70

Why

Docker HEAD routes mapped to handleProxy, which ran a full Fetch + io.Copy — downloading the entire blob (and fetching upstream on a miss) only for net/http to discard the body. HEAD existence checks (manifests, blobs) are common.

Changes

  • Add Engine.Head: answers cached artifacts/indexes from store metadata (no blob download); on a miss issues an upstream HEAD (with bearer-token handling) and never caches a body.
  • Route HEAD /v2/{remote}/* to a dedicated handleProxyHead that writes headers only.
  • Add e2e tests for HEAD on a blocklisted path (403) and an unknown remote (404).

Note

headUpstream uses http.DefaultClient to build cleanly on master; it will pick up the shared timeout-configured client from #67 once that merges.

Validation

  • make e2e passes (includes new HEAD tests).
Fixes #70 ## Why Docker `HEAD` routes mapped to `handleProxy`, which ran a full `Fetch` + `io.Copy` — downloading the entire blob (and fetching upstream on a miss) only for net/http to discard the body. HEAD existence checks (manifests, blobs) are common. ## Changes - Add `Engine.Head`: answers cached artifacts/indexes from store metadata (no blob download); on a miss issues an upstream `HEAD` (with bearer-token handling) and never caches a body. - Route `HEAD /v2/{remote}/*` to a dedicated `handleProxyHead` that writes headers only. - Add e2e tests for HEAD on a blocklisted path (403) and an unknown remote (404). ## Note `headUpstream` uses `http.DefaultClient` to build cleanly on master; it will pick up the shared timeout-configured client from #67 once that merges. ## Validation - `make e2e` passes (includes new HEAD tests).
unkinben added 1 commit 2026-07-02 00:37:12 +10:00
fix: resolve HEAD requests from metadata without streaming the body
ci/woodpecker/pr/test Pipeline was successful
ci/woodpecker/pr/pre-commit Pipeline was successful
ci/woodpecker/pr/build Pipeline was successful
c129a09541
Docker HEAD routes ran a full Fetch + io.Copy, downloading the whole blob
(and fetching upstream on a miss) only for net/http to discard the body.
Add Engine.Head, which answers cached artifacts/indexes from store
metadata and otherwise issues an upstream HEAD, and route HEAD to a
dedicated handler that writes headers only.

Refs #70
benvin merged commit b59cc45765 into master 2026-07-02 22:06:51 +10:00
benvin deleted branch benvin/head-metadata-only 2026-07-02 22:06:51 +10:00
Sign in to join this conversation.
No Reviewers
No Label
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: unkin/artifactapi#89