mirror of
https://github.com/project-zot/zot.git
synced 2026-06-17 12:58:02 +08:00
1a1f84d184
* fix(api): set blob response Content-Type from OCI descriptor Blob HEAD responses had no Content-Type and GET responses echoed the request's Accept header verbatim, which produced missing or malformed media types and left multipart/byteranges parts without a per-part Content-Type. This breaks OCI distribution-spec conformance and consumers like stargz-snapshotter that need a well-formed layer media type. Add a blobResponseMediaType helper that resolves the descriptor's MediaType via GetBlobDescriptorFromRepo and falls back to application/octet-stream. Use it in CheckBlob (HEAD), GetBlob full (200), GetBlob single-range (206), and per-part in writeMultipartRanges (206 multipart). Lookup is deferred until after the blob is known to exist. Cover the new behaviour with mock-based unit tests in routes_test.go and end-to-end assertions in TestPullRange. Signed-off-by: Andrei Aaron <andreifdaaron@gmail.com> * perf(api): stream multipart blob ranges lazily with precomputed Content-Length writeMultipartRanges previously opened every range reader up front and emitted no Content-Length, so an N-range request held N concurrent storage readers (and their fds / read buffers) per response window and forced chunked encoding on HTTP/1.1 — neither friendly to proxies nor to fan-out scenarios like stargz lazy pulls. Signed-off-by: Andrei Aaron <andreifdaaron@gmail.com> --------- Signed-off-by: Andrei Aaron <andreifdaaron@gmail.com>