From 1589d70bcb522e49c75632c4e0edff52d2e459c2 Mon Sep 17 00:00:00 2001 From: Miloslav Trmač Date: Sat, 11 Sep 2021 22:39:25 +0200 Subject: Use Header.Values in GetCredentials.has MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit It's possibly a bit more expensive, but semantically safer because it does header normalization. And we'll regain the cost by not looking up the value repeatedly. Signed-off-by: Miloslav Trmač --- pkg/auth/auth.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'pkg/auth') diff --git a/pkg/auth/auth.go b/pkg/auth/auth.go index 8e4cb6959..9a4e2af85 100644 --- a/pkg/auth/auth.go +++ b/pkg/auth/auth.go @@ -34,8 +34,8 @@ const XRegistryConfigHeader HeaderAuthName = "X-Registry-Config" // the necessary authentication information for libpod operations func GetCredentials(r *http.Request) (*types.DockerAuthConfig, string, error) { has := func(key HeaderAuthName) bool { - hdr, found := r.Header[key.String()] - return found && len(hdr) > 0 + hdr := r.Header.Values(key.String()) + return len(hdr) > 0 } switch { case has(XRegistryConfigHeader): -- cgit v1.2.3-54-g00ecf