mirror of
https://github.com/containers/podman.git
synced 2025-06-25 12:20:42 +08:00
Use Header.Values in GetCredentials.has
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č <mitr@redhat.com>
This commit is contained in:
@ -34,8 +34,8 @@ const XRegistryConfigHeader HeaderAuthName = "X-Registry-Config"
|
|||||||
// the necessary authentication information for libpod operations
|
// the necessary authentication information for libpod operations
|
||||||
func GetCredentials(r *http.Request) (*types.DockerAuthConfig, string, error) {
|
func GetCredentials(r *http.Request) (*types.DockerAuthConfig, string, error) {
|
||||||
has := func(key HeaderAuthName) bool {
|
has := func(key HeaderAuthName) bool {
|
||||||
hdr, found := r.Header[key.String()]
|
hdr := r.Header.Values(key.String())
|
||||||
return found && len(hdr) > 0
|
return len(hdr) > 0
|
||||||
}
|
}
|
||||||
switch {
|
switch {
|
||||||
case has(XRegistryConfigHeader):
|
case has(XRegistryConfigHeader):
|
||||||
|
Reference in New Issue
Block a user