summaryrefslogtreecommitdiff
path: root/spartan/request.go
diff options
context:
space:
mode:
Diffstat (limited to 'spartan/request.go')
-rw-r--r--spartan/request.go22
1 files changed, 1 insertions, 21 deletions
diff --git a/spartan/request.go b/spartan/request.go
index c88a20b..36dd225 100644
--- a/spartan/request.go
+++ b/spartan/request.go
@@ -2,7 +2,6 @@ package spartan
import (
"bufio"
- "bytes"
"errors"
"io"
"net/url"
@@ -59,6 +58,7 @@ func ParseRequest(rdr io.Reader) (*types.Request, int, error) {
Path: path,
RawPath: path,
},
+ Meta: &io.LimitedReader{R: bufrdr, N: int64(contentlen)},
}, contentlen, nil
}
@@ -81,23 +81,3 @@ func GetRequestBody(request *types.Request) io.Reader {
}
return nil
}
-
-// SetRequestBody adds an io.Reader as a request body.
-//
-// It is for use in clients, preparing the request to be sent.
-//
-// This function will read the entire contents into memory unless
-// the reader is already an *io.LimitedReader.
-func SetRequestBody(request *types.Request, body io.Reader) error {
- if rdr, ok := body.(*io.LimitedReader); ok {
- request.Meta = rdr
- return nil
- }
-
- buf, err := io.ReadAll(body)
- if err != nil {
- return err
- }
- request.Meta = io.LimitReader(bytes.NewBuffer(buf), int64(len(buf)))
- return nil
-}