func ParseBasicAuthHeader(h http.Header) (userid, password string, err error) {
	parts := strings.Fields(h.Get("Authorization"))
	if len(parts) != 2 || parts[0] != "Basic" {
		return "", "", fmt.Errorf("invalid or missing HTTP auth header")
	}
	// Challenge is a base64-encoded "tag:pass" string.
	// See RFC 2617, Section 2.
	challenge, err := base64.StdEncoding.DecodeString(parts[1])
	if err != nil {
		return "", "", fmt.Errorf("invalid HTTP auth encoding")
	}
	tokens := strings.SplitN(string(challenge), ":", 2)
	if len(tokens) != 2 {
		return "", "", fmt.Errorf("invalid HTTP auth contents")
	}
	return tokens[0], tokens[1], nil
}
// ParseBasicAuth attempts to find an Authorization header in the supplied
// http.Header and if found parses it as a Basic header. See 2 (end of page 4)
// http://www.ietf.org/rfc/rfc2617.txt "To receive authorization, the client
// sends the userid and password, separated by a single colon (":") character,
// within a base64 encoded string in the credentials."
ParseBasicAuth attempts to find an Authorization header in the supplied
http.Header and if found parses it as a Basic header.
// ParseBasicAuth attempts to find an Authorization header in the supplied // http . Header and if found parses it as a Basic header . See 2 ( end of page 4 ) // http : // www . ietf . org / rfc / rfc2617 . txt " To receive authorization the client // sends the userid and password separated by a single colon ( " : " ) character // within a base64 encoded string in the credentials . "
func ParseBasicAuthHeader(h http.Header) (userid, password string, err error) {
	parts := strings.Fields(h.Get("Authorization"))
	if len(parts) != 2 || parts[0] != "Basic" {
		return "", "", fmt.Errorf("invalid or missing HTTP auth header")
	}
	challenge, err := base64.StdEncoding.DecodeString(parts[1])
	if err != nil {
		return "", "", fmt.Errorf("invalid HTTP auth encoding")
	}
	tokens := strings.SplitN(string(challenge), ":", 2)
	if len(tokens) != 2 {
		return "", "", fmt.Errorf("invalid HTTP auth contents")
	}
	return tokens[0], tokens[1], nil
}
func ParseBasicAuthHeader ( h http . Header ) ( userid , password string , err error ) { parts := strings . Fields ( h . Get ( " " ) ) if len ( parts ) != 2 || parts [ 0 ] != " " { return " " , " " , fmt . Errorf ( " " ) } challenge , err := base64 . StdEncoding . DecodeString ( parts [ 1 ] ) if err != nil { return " " , " " , fmt . Errorf ( " " ) } tokens := strings . SplitN ( string ( challenge ) , " " , 2 ) if len ( tokens ) != 2 { return " " , " " , fmt . Errorf ( " " ) } return tokens [ 0 ] , tokens [ 1 ] , nil }
ParseBasicAuth attempts to find an Authorization header in the supplied
http.Header and if found parses it as a Basic header.
ParseBasicAuth attempts to find an Authorization header in the supplied http . Header and if found parses it as a Basic header .
// Challenge is a base64-encoded "tag:pass" string. // See RFC 2617, Section 2.