httputils

package
v0.48.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: 5 Imported by: 0

Documentation

Index

Constants

View Source
const MaxBodyBytes = 10 * 1024

MaxBodyBytes is the maximum number of bytes the SDK captures from an HTTP body for attaching to events or spans. Bodies larger than this are dropped rather than truncated, to avoid invalid partial structured payloads.

Variables

This section is empty.

Functions

func ReadBody added in v0.48.0

func ReadBody(r io.Reader) []byte

ReadBody reads up to MaxBodyBytes from r and returns the bytes read.

Types

type LimitedBuffer added in v0.48.0

type LimitedBuffer struct {
	Capacity int

	bytes.Buffer
	// contains filtered or unexported fields
}

LimitedBuffer is like a bytes.Buffer, but limited to store at most Capacity bytes. Any writes past the capacity are silently discarded, similar to io.Discard.

func NewLimitedBuffer added in v0.48.0

func NewLimitedBuffer(capacity int) *LimitedBuffer

NewLimitedBuffer returns a LimitedBuffer with the given capacity.

func NewLimitedBufferFromBytes added in v0.48.0

func NewLimitedBufferFromBytes(capacity int, b []byte) *LimitedBuffer

NewLimitedBufferFromBytes returns a LimitedBuffer initialized from b.

func (*LimitedBuffer) Overflow added in v0.48.0

func (b *LimitedBuffer) Overflow() bool

Overflow returns true if the LimitedBuffer discarded bytes written to it.

func (*LimitedBuffer) Write added in v0.48.0

func (b *LimitedBuffer) Write(p []byte) (n int, err error)

Write implements io.Writer.

type ReadCloser added in v0.48.0

type ReadCloser struct {
	io.Reader
	io.Closer
}

ReadCloser combines an io.Reader and an io.Closer to implement io.ReadCloser.

type WrapResponseWriter

type WrapResponseWriter interface {
	http.ResponseWriter
	// Status returns the HTTP status of the request, or 200 if one has not
	// yet been sent.
	Status() int
	// BytesWritten returns the total number of bytes sent to the client.
	BytesWritten() int
	// Tee causes the response body to be written to the given io.Writer in
	// addition to proxying the writes through. Only one io.Writer can be
	// tee'd to at once: setting a second one will overwrite the first.
	// Writes will be sent to the proxy before being written to this
	// io.Writer. It is illegal for the tee'd writer to be modified
	// concurrently with writes.
	Tee(io.Writer)
	// Unwrap returns the original proxied target.
	Unwrap() http.ResponseWriter
}

WrapResponseWriter is a proxy around an http.ResponseWriter that allows you to hook into various parts of the response process.

func NewWrapResponseWriter

func NewWrapResponseWriter(w http.ResponseWriter, protoMajor int) WrapResponseWriter

Jump to

Keyboard shortcuts

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