From 06acf2def51b39593c86d7208ac7f480356e7efb Mon Sep 17 00:00:00 2001 From: bin liu Date: Tue, 26 Sep 2023 15:14:57 +0800 Subject: [PATCH] remove go build directive for older go version Go 1.4 is too old and should be dropped safely. Signed-off-by: bin liu --- registry/handlers/basicauth.go | 3 -- registry/handlers/basicauth_prego14.go | 42 -------------------------- 2 files changed, 45 deletions(-) delete mode 100644 registry/handlers/basicauth_prego14.go diff --git a/registry/handlers/basicauth.go b/registry/handlers/basicauth.go index a41965dc..081b6849 100644 --- a/registry/handlers/basicauth.go +++ b/registry/handlers/basicauth.go @@ -1,6 +1,3 @@ -//go:build go1.4 -// +build go1.4 - package handlers import ( diff --git a/registry/handlers/basicauth_prego14.go b/registry/handlers/basicauth_prego14.go deleted file mode 100644 index 01290adf..00000000 --- a/registry/handlers/basicauth_prego14.go +++ /dev/null @@ -1,42 +0,0 @@ -//go:build !go1.4 -// +build !go1.4 - -package handlers - -import ( - "encoding/base64" - "net/http" - "strings" -) - -// NOTE(stevvooe): This is basic auth support from go1.4 present to ensure we -// can compile on go1.3 and earlier. - -// BasicAuth returns the username and password provided in the request's -// Authorization header, if the request uses HTTP Basic Authentication. -// See RFC 2617, Section 2. -func basicAuth(r *http.Request) (username, password string, ok bool) { - auth := r.Header.Get("Authorization") - if auth == "" { - return - } - return parseBasicAuth(auth) -} - -// parseBasicAuth parses an HTTP Basic Authentication string. -// "Basic QWxhZGRpbjpvcGVuIHNlc2FtZQ==" returns ("Aladdin", "open sesame", true). -func parseBasicAuth(auth string) (username, password string, ok bool) { - if !strings.HasPrefix(auth, "Basic ") { - return - } - c, err := base64.StdEncoding.DecodeString(strings.TrimPrefix(auth, "Basic ")) - if err != nil { - return - } - cs := string(c) - s := strings.IndexByte(cs, ':') - if s < 0 { - return - } - return cs[:s], cs[s+1:], true -}