Skip to content

Commit

Permalink
fix: Improve Digest WWW-Authenticate response header parsing compatib…
Browse files Browse the repository at this point in the history
…ility (#735)

Co-authored-by: Jeevanandam M <jeeva@myjeeva.com>
  • Loading branch information
bearki and jeevatkm committed Dec 27, 2023
1 parent 577fed8 commit 74050fd
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions digest.go
Expand Up @@ -133,14 +133,17 @@ func parseChallenge(input string) (*challenge, error) {
return nil, ErrDigestBadChallenge
}
s = strings.Trim(s[7:], ws)
sl := strings.Split(s, ", ")
sl := strings.Split(s, ",")
c := &challenge{}
var r []string
for i := range sl {
sl[i] = strings.TrimSpace(sl[i])
r = strings.SplitN(sl[i], "=", 2)
if len(r) != 2 {
return nil, ErrDigestBadChallenge
}
r[0] = strings.TrimSpace(r[0])
r[1] = strings.TrimSpace(r[1])
switch r[0] {
case "realm":
c.realm = strings.Trim(r[1], qs)
Expand All @@ -151,9 +154,9 @@ func parseChallenge(input string) (*challenge, error) {
case "opaque":
c.opaque = strings.Trim(r[1], qs)
case "stale":
c.stale = r[1]
c.stale = strings.Trim(r[1], qs)
case "algorithm":
c.algorithm = r[1]
c.algorithm = strings.Trim(r[1], qs)
case "qop":
c.qop = strings.Trim(r[1], qs)
case "charset":
Expand Down

0 comments on commit 74050fd

Please sign in to comment.