Skip to content
Open
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: 9 additions & 0 deletions client.go
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,15 @@ func getBodyReaderAndContentLength(rawBody interface{}) (ReaderFunc, int64, erro
}
contentLength = int64(len(buf))

// If a regular string, we can read it over and over via new
// readers
case string:
buf := body
bodyReader = func() (io.Reader, error) {
return strings.NewReader(buf), nil
}
contentLength = int64(len(buf))

// If a bytes.Buffer we can read the underlying byte slice over and
// over
case *bytes.Buffer:
Expand Down
2 changes: 2 additions & 0 deletions client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,8 @@ func TestClient_Do(t *testing.T) {
// io.ReadSeeker
testClientDo(t, strings.NewReader(string(testBytes)))
// io.Reader
testClientDo(t, string(testBytes))
// io.Reader
testClientDo(t, &custReader{})
}

Expand Down