Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions .github/workflows/golangci-lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,11 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Install Go
uses: actions/setup-go@v3
with:
go-version: 1.18
- name: golangci-lint
uses: golangci/golangci-lint-action@v2.5.1
uses: golangci/golangci-lint-action@v3.2.0
with:
version: v1.42.0
args: --timeout 2m0s
version: v1.46.2
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# A Self-Documenting Makefile: http://marmelab.com/blog/2016/02/29/auto-documented-makefile.html

GOLANGCI_VERSION=v1.42.0
GOLANGCI_VERSION=v1.46.2
COVERAGE=coverage.out

.PHONY: setup
Expand Down
25 changes: 12 additions & 13 deletions digest.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,6 @@ import (
"fmt"
"hash"
"io"
"io/ioutil"
"net/http"
"strings"
)
Expand Down Expand Up @@ -250,21 +249,21 @@ func (c *credentials) authorize() (string, error) {
if err != nil {
return "", ErrAlgNotImplemented
}
sl := []string{fmt.Sprintf(`username="%s"`, c.Username)}
sl = append(sl, fmt.Sprintf(`realm="%s"`, c.Realm),
fmt.Sprintf(`nonce="%s"`, c.Nonce),
fmt.Sprintf(`uri="%s"`, c.DigestURI),
fmt.Sprintf(`response="%s"`, resp))
sl := []string{fmt.Sprintf(`username=%q`, c.Username)}
sl = append(sl, fmt.Sprintf(`realm=%q`, c.Realm),
fmt.Sprintf(`nonce=%q`, c.Nonce),
fmt.Sprintf(`uri=%q`, c.DigestURI),
fmt.Sprintf(`response=%q`, resp))
if c.Algorithm != "" {
sl = append(sl, fmt.Sprintf(`algorithm="%s"`, c.Algorithm))
sl = append(sl, fmt.Sprintf(`algorithm=%q`, c.Algorithm))
}
if c.Opaque != "" {
sl = append(sl, fmt.Sprintf(`opaque="%s"`, c.Opaque))
sl = append(sl, fmt.Sprintf(`opaque=%q`, c.Opaque))
}
if c.MessageQop != "" {
sl = append(sl, fmt.Sprintf("qop=%s", c.MessageQop),
fmt.Sprintf("nc=%08x", c.NonceCount),
fmt.Sprintf(`cnonce="%s"`, c.Cnonce))
fmt.Sprintf(`cnonce=%q`, c.Cnonce))
}
return fmt.Sprintf("Digest %s", strings.Join(sl, ", ")), nil
}
Expand Down Expand Up @@ -315,12 +314,12 @@ func (t *Transport) RoundTrip(req *http.Request) (*http.Response, error) {
// before the RoundTrip(origReq) call. If GetBody is unavailable, read
// the body into a memory buffer and use it for both requests.
if req.Body != nil && req.GetBody == nil {
body, err := ioutil.ReadAll(req.Body)
body, err := io.ReadAll(req.Body)
if err != nil {
return nil, err
}
req.Body = ioutil.NopCloser(bytes.NewBuffer(body))
origReq.Body = ioutil.NopCloser(bytes.NewBuffer(body))
req.Body = io.NopCloser(bytes.NewBuffer(body))
origReq.Body = io.NopCloser(bytes.NewBuffer(body))
}
// Make a request to get the 401 that contains the challenge.
challenge, resp, err := t.fetchChallenge(req)
Expand Down Expand Up @@ -375,7 +374,7 @@ func (t *Transport) fetchChallenge(req *http.Request) (string, *http.Response, e
// won't reuse it anyway.
const maxBodySlurpSize = 2 << 10
if resp.ContentLength == -1 || resp.ContentLength <= maxBodySlurpSize {
_, _ = io.CopyN(ioutil.Discard, resp.Body, maxBodySlurpSize)
_, _ = io.CopyN(io.Discard, resp.Body, maxBodySlurpSize)
}

resp.Body.Close()
Expand Down