Documentation
¶
Overview ¶
Package reqbody builds outbound HTTP request bodies over an in-memory buffer that stop referencing the buffer once the transport is done with it.
A *bytes.Reader body stays reachable from the client transport (and from Response.Request) for as long as the response is read, so a large request stays pinned for the whole length of a long stream. These readers drop the buffer at EOF or Close instead; Attach uses them only above pinnedMax. Streamed bodies of unknown size are out of scope.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Attach ¶
Attach sets b as req's body with its Content-Length and a GetBody for transport retries, as http.NewRequest does for a *bytes.Reader. For bodies above pinnedMax the returned release drops GetBody's reference to b; call it once the response is in hand, after which no transport retry can rewind the body.
func NewReader ¶
func NewReader(b []byte) io.ReadCloser
NewReader returns a reader over b that drops b once read to the end or closed.
Types ¶
This section is empty.