Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactored to not use ioutil #84

Merged
merged 1 commit into from
Jun 25, 2023
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
3 changes: 1 addition & 2 deletions sling.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package sling
import (
"encoding/base64"
"io"
"io/ioutil"
"net/http"
"net/url"

Expand Down Expand Up @@ -390,7 +389,7 @@ func (s *Sling) Do(req *http.Request, successV, failureV interface{}) (*http.Res
// reuse HTTP/1.x "keep-alive" TCP connections if the Body is
// not read to completion and closed.
// See: https://golang.org/pkg/net/http/#Response
defer io.Copy(ioutil.Discard, resp.Body)
defer io.Copy(io.Discard, resp.Body)

// Don't try to decode on 204s or Content-Length is 0
if resp.StatusCode == http.StatusNoContent || resp.ContentLength == 0 {
Expand Down
3 changes: 1 addition & 2 deletions sling_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import (
"errors"
"fmt"
"io"
"io/ioutil"
"math"
"net"
"net/http"
Expand Down Expand Up @@ -385,7 +384,7 @@ func TestBodyFormSetter(t *testing.T) {
}

func TestBodySetter(t *testing.T) {
fakeInput := ioutil.NopCloser(strings.NewReader("test"))
fakeInput := io.NopCloser(strings.NewReader("test"))
fakeBodyProvider := bodyProvider{body: fakeInput}

cases := []struct {
Expand Down