From cd21842fb675d38d73a4322c025993b6debf93d3 Mon Sep 17 00:00:00 2001 From: yyeltsyn Date: Fri, 3 Feb 2023 20:59:54 +0300 Subject: [PATCH] fix: Allow concurrent use for DigestAuth (#69) fix: Allow concurrent use for DigestAuth --- digestAuth.go | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/digestAuth.go b/digestAuth.go index 4a5eb62..d171670 100644 --- a/digestAuth.go +++ b/digestAuth.go @@ -34,11 +34,15 @@ func (d *DigestAuth) Pass() string { // Authorize the current request func (d *DigestAuth) Authorize(req *http.Request, method string, path string) { - d.digestParts["uri"] = path - d.digestParts["method"] = method - d.digestParts["username"] = d.user - d.digestParts["password"] = d.pw - req.Header.Set("Authorization", getDigestAuthorization(d.digestParts)) + parts := make(map[string]string, len(d.digestParts)+4) + for k, v := range d.digestParts { + parts[k] = v + } + parts["uri"] = path + parts["method"] = method + parts["username"] = d.user + parts["password"] = d.pw + req.Header.Set("Authorization", getDigestAuthorization(parts)) } func digestParts(resp *http.Response) map[string]string {