Skip to content
This repository was archived by the owner on Jun 21, 2022. It is now read-only.

Commit 858170f

Browse files
committed
minor fixes
1 parent ddd37fe commit 858170f

File tree

1 file changed

+8
-10
lines changed

1 file changed

+8
-10
lines changed

digest_auth_client.go

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -22,21 +22,20 @@ type DigestTransport struct {
2222
Username string
2323
}
2424

25-
func NewRequest(username string, password string, method string, uri string, body string) DigestRequest {
25+
func NewRequest(username, password, method, uri, body string) DigestRequest {
2626
dr := DigestRequest{}
2727
dr.UpdateRequest(username, password, method, uri, body)
2828
return dr
2929
}
3030

31-
func NewTransport(username string, password string) DigestTransport {
31+
func NewTransport(username, password string) DigestTransport {
3232
dt := DigestTransport{}
3333
dt.Password = password
3434
dt.Username = username
3535
return dt
3636
}
3737

38-
func (dr *DigestRequest) UpdateRequest(username string,
39-
password string, method string, uri string, body string) *DigestRequest {
38+
func (dr *DigestRequest) UpdateRequest(username, password, method, uri, body string) *DigestRequest {
4039

4140
dr.Body = body
4241
dr.Method = method
@@ -98,7 +97,7 @@ func (dr *DigestRequest) executeNewDigest(resp *http.Response) (*http.Response,
9897

9998
waString := resp.Header.Get("WWW-Authenticate")
10099
if waString == "" {
101-
return nil, fmt.Errorf("Failed to get WWW-Authenticate header, please check your server configuration.")
100+
return nil, fmt.Errorf("failed to get WWW-Authenticate header, please check your server configuration")
102101
}
103102
wa = newWwwAuthenticate(waString)
104103
dr.Wa = wa
@@ -108,12 +107,12 @@ func (dr *DigestRequest) executeNewDigest(resp *http.Response) (*http.Response,
108107
}
109108
authString := auth.toString()
110109

111-
if resp, err := dr.executeRequest(authString); err != nil {
110+
if _, err := dr.executeRequest(authString); err != nil {
112111
return nil, err
113-
} else {
114-
dr.Auth = auth
115-
return resp, nil
116112
}
113+
114+
dr.Auth = auth
115+
return resp, nil
117116
}
118117

119118
func (dr *DigestRequest) executeExistingDigest() (*http.Response, error) {
@@ -141,7 +140,6 @@ func (dr *DigestRequest) executeRequest(authString string) (*http.Response, erro
141140
return nil, err
142141
}
143142

144-
// fmt.Printf("AUTHSTRING: %s\n\n", authString)
145143
req.Header.Add("Authorization", authString)
146144

147145
client := &http.Client{

0 commit comments

Comments
 (0)