httpx

package
v0.9.0 Latest Latest
Warning

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

Go to latest
Published: Nov 2, 2026 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Overview

Package httpx holds bounded body reads and a client with sane defaults.

Index

Constants

View Source
const (
	// DefaultMaxBody caps an API response read into memory.
	DefaultMaxBody int64 = 32 << 20
	// MaxDownload caps a file-style response (CSV export, deploy log) read into memory.
	MaxDownload int64 = 256 << 20
)

Variables

View Source
var ErrBodyTooLarge = errors.New("httpx: response body exceeds limit")

ErrBodyTooLarge is returned when a body exceeds its read limit.

Functions

func NewClient

func NewClient(timeout time.Duration) *http.Client

NewClient returns a client with an overall timeout and a transport that bounds dial, TLS handshake and header waits.

func ReadAll

func ReadAll(r io.Reader, limit int64) ([]byte, error)

ReadAll reads at most limit bytes from r and fails with ErrBodyTooLarge rather than silently truncating when there is more.

func ReadBody

func ReadBody(r io.Reader) ([]byte, error)

ReadBody is ReadAll with DefaultMaxBody.

Types

This section is empty.

Jump to

Keyboard shortcuts

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