reqbody

package
v0.20.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 10, 2026 License: Apache-2.0 Imports: 5 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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

func Attach(req *http.Request, b []byte) (release func())

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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL