ownedstream

package
v0.19.0 Latest Latest
Warning

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

Go to latest
Published: Nov 11, 2026 License: MIT Imports: 10 Imported by: 0

Documentation

Overview

Package ownedstream retains a borrowed stream until reads and close actually return. It is used by both sides of one outbound HTTP transport attempt.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Nil

func Nil(v any) bool

Types

type Body

type Body struct {
	// contains filtered or unexported fields
}

func New

func New(ctx context.Context, source io.ReadCloser, maximum, expected int64, tap *httpcapture.Tap) (*Body, error)

New owns source until Close. tap, when not nil, observes every returned byte and how the stream ended; it never changes what a reader receives.

func (*Body) BytesRead

func (b *Body) BytesRead() int64

BytesRead counts bytes returned to readers.

func (*Body) Close

func (b *Body) Close() error

Close interrupts a read using the underlying io.ReadCloser contract, then waits for that read's actual exit. It never holds readMu while closing source.

func (*Body) Err

func (b *Body) Err() error

Err includes a swallowed read failure after a custom transport/callback returns. A normal EOF is not a failure.

func (*Body) Exceeded added in v0.19.0

func (b *Body) Exceeded() bool

Exceeded reports whether the source returned more than the byte bound.

func (*Body) Read

func (b *Body) Read(p []byte) (int, error)

Jump to

Keyboard shortcuts

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