diff --git a/client.go b/client.go index f40d241..0667a51 100644 --- a/client.go +++ b/client.go @@ -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: diff --git a/client_test.go b/client_test.go index b3f8e6d..bcfc0d0 100644 --- a/client_test.go +++ b/client_test.go @@ -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{}) }