fix(requests.go): allow www-authenticate to be case-insensitive. close #32
This commit is contained in:
parent
38f79aeaf1
commit
ff7f737904
@ -43,10 +43,15 @@ func (c *Client) req(method, path string, body io.Reader, intercept func(*http.R
|
|||||||
}
|
}
|
||||||
|
|
||||||
if rs.StatusCode == 401 && c.auth.Type() == "NoAuth" {
|
if rs.StatusCode == 401 && c.auth.Type() == "NoAuth" {
|
||||||
if strings.Index(rs.Header.Get("Www-Authenticate"), "Digest") > -1 {
|
|
||||||
|
wwwAuthenticateHeader := strings.ToLower(rs.Header.Get("Www-Authenticate"))
|
||||||
|
|
||||||
|
if strings.Index(wwwAuthenticateHeader, "digest") > -1 {
|
||||||
c.auth = &DigestAuth{c.auth.User(), c.auth.Pass(), digestParts(rs)}
|
c.auth = &DigestAuth{c.auth.User(), c.auth.Pass(), digestParts(rs)}
|
||||||
} else if strings.Index(rs.Header.Get("Www-Authenticate"), "Basic") > -1 {
|
|
||||||
|
} else if strings.Index(wwwAuthenticateHeader, "basic") > -1 {
|
||||||
c.auth = &BasicAuth{c.auth.User(), c.auth.Pass()}
|
c.auth = &BasicAuth{c.auth.User(), c.auth.Pass()}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
return rs, newPathError("Authorize", c.root, rs.StatusCode)
|
return rs, newPathError("Authorize", c.root, rs.StatusCode)
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user