httpx

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Jul 14, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

Package httpx contains small HTTP safety helpers for broker proxies.

Index

Constants

This section is empty.

Variables

View Source
var ErrBodyTooLarge = errors.New("body too large")

ErrBodyTooLarge is returned when ReadLimited sees more bytes than allowed.

Functions

func CopyHeaders

func CopyHeaders(dst http.Header, src http.Header, drop HeaderDropper)

CopyHeaders copies src into dst unless drop returns true for the header name.

func DecodeJSON added in v0.2.0

func DecodeJSON(reader io.Reader, limit int64, out any, closed bool) error

DecodeJSON reads and strictly decodes one bounded JSON value. Set closed for request schemas that reject unknown object fields.

func HopByHopHeader

func HopByHopHeader(key string) bool

HopByHopHeader reports whether key is unsafe to forward through a proxy.

func NoStore

func NoStore(header http.Header)

NoStore sets response headers for broker responses that must not be cached.

func ProxyRequestHeader

func ProxyRequestHeader(key string) bool

ProxyRequestHeader reports whether key should be dropped before upstreaming.

func ProxyResponseHeader

func ProxyResponseHeader(key string) bool

ProxyResponseHeader reports whether key should be dropped before responding.

func ReadLimited

func ReadLimited(reader io.Reader, limit int64) ([]byte, error)

ReadLimited reads reader up to limit bytes and fails if one more byte exists.

func RequestCredentialHeader

func RequestCredentialHeader(key string) bool

RequestCredentialHeader reports whether key carries client credentials.

func ResponseCredentialHeader

func ResponseCredentialHeader(key string) bool

ResponseCredentialHeader reports whether key may expose upstream auth state.

func RewrittenBodyHeader

func RewrittenBodyHeader(key string) bool

RewrittenBodyHeader reports whether key is invalid after rewriting a body.

Types

type HeaderDropper

type HeaderDropper func(string) bool

HeaderDropper reports whether a header should be omitted when copied.

func DropAny

func DropAny(droppers ...HeaderDropper) HeaderDropper

DropAny combines multiple header drop predicates.

Jump to

Keyboard shortcuts

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