Skip to content

Commit

Permalink
docs: net/anyhttp: add comments
Browse files Browse the repository at this point in the history
  • Loading branch information
grokify committed Jan 7, 2021
1 parent a4d9bd2 commit d2bd97e
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
5 changes: 5 additions & 0 deletions net/anyhttp/fasthttp.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,11 @@ func (w ResponseFastHttp) SetBodyBytes(body []byte) (int, error) {
w.Raw.SetBody(body)
return -1, nil
}

// SetBodyStream takes an `io.Reader` and an optional `bodySize`.
// If bodySize is >= 0, then bodySize bytes must be provided by
// bodyStream before returning io.EOF. If bodySize < 0, then
// bodyStream is read until io.EOF.
func (w ResponseFastHttp) SetBodyStream(bodyStream io.Reader, bodySize int) error {
w.Raw.SetBodyStream(bodyStream, bodySize)
return nil
Expand Down
3 changes: 3 additions & 0 deletions net/anyhttp/nethttp.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,9 @@ func (w ResponseNetHttp) SetBodyBytes(body []byte) (int, error) {
w.Raw.Write(body)
return -1, nil
}

// SetBodyStream takes an `io.Reader`. `bodySize` is accepted but
// ignored to fulfill the `Response` interface requirement.
func (w ResponseNetHttp) SetBodyStream(bodyStream io.Reader, bodySize int) error {
bytes, err := ioutil.ReadAll(bodyStream)
if err != nil {
Expand Down

0 comments on commit d2bd97e

Please sign in to comment.