Skip to content

Commit d595c54

Browse files
committed
use method from original request
1 parent 77aabc8 commit d595c54

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

authentication.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ func (s *AuthenticationService) SetDigestAuth(username, password string) {
5151
// returns 401 Unauthorized and authType was set to authTypeDigest. The
5252
// resulting string is used to set the Authorization header before retrying
5353
// the request.
54-
func (s *AuthenticationService) digestAuthHeader(method string, response *http.Response) (string, error) {
54+
func (s *AuthenticationService) digestAuthHeader(response *http.Response) (string, error) {
5555
authenticateHeader := response.Header.Get("WWW-Authenticate")
5656
if authenticateHeader == "" {
5757
return "", fmt.Errorf("WWW-Authenticate header is missing")
@@ -112,7 +112,7 @@ func (s *AuthenticationService) digestAuthHeader(method string, response *http.R
112112

113113
// A2
114114
h = md5.New()
115-
A2 := fmt.Sprintf("%s:%s", method, uriHeader)
115+
A2 := fmt.Sprintf("%s:%s", response.Request.Method, uriHeader)
116116
io.WriteString(h, A2)
117117
HA2 := fmt.Sprintf("%x", h.Sum(nil))
118118

gerrit.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -277,7 +277,7 @@ func (c *Client) addAuthentication(req *http.Request) error {
277277
defer response.Body.Close()
278278

279279
if response.StatusCode == http.StatusUnauthorized {
280-
authorization, err := c.Authentication.digestAuthHeader(req.Method, response)
280+
authorization, err := c.Authentication.digestAuthHeader(response)
281281

282282
if err != nil {
283283
return err

0 commit comments

Comments
 (0)