From d11ca5f196324dd59ab8cc5abdfcd0442e0780d1 Mon Sep 17 00:00:00 2001 From: Ryan Levick Date: Tue, 25 Feb 2025 09:49:52 +0100 Subject: [PATCH] Filter empty DOCKER_DIGEST_HEADER. The spec says the header MUST be used if "if present on the response", but does not define what present means. If present means "the key is there", then the current behavior is correct and the server is not spec compliant. However, if it means "the key is there and not empty", then the client needs to be more forgiving than it currently is. Signed-off-by: Ryan Levick --- src/digest.rs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/digest.rs b/src/digest.rs index 3cc3c6e7..89c574cb 100644 --- a/src/digest.rs +++ b/src/digest.rs @@ -95,7 +95,12 @@ impl Digester { pub fn digest_header_value(headers: HeaderMap) -> Result> { headers .get(DOCKER_DIGEST_HEADER) - .map(|hv| hv.to_str().map(|s| s.to_string())) + .and_then(|hv| { + hv.to_str() + // Treat present but empty header as missing + .map(|s| (!s.is_empty()).then(|| s.to_string())) + .transpose() + }) .transpose() .map_err(DigestError::from) }