Documentation
¶
Overview ¶
Package download provides validated full and ranged streams for extensions and built-in commands. It owns transfer bounds, retries, representation consistency, progress timeouts, and response-length checks; callers supply a Transport that owns authentication and source/URL policy, and they choose the destination that consumes Stream.Body.
Index ¶
Constants ¶
const ( // DefaultPartSize keeps a 100 MiB object near 13 requests while capping replay at 8 MiB. DefaultPartSize = int64(8 * 1024 * 1024) // DefaultPartRetries tolerates three transient failures without prolonged retrying. DefaultPartRetries = 3 // DefaultRetryDelay keeps three local backoffs below one second before jitter. DefaultRetryDelay = 100 * time.Millisecond // DefaultRetryWaitBudget caps cumulative local sleep for interactive callers. DefaultRetryWaitBudget = 3 * time.Second // DefaultIdleTimeout detects a dead connection within a minute without limiting slow progress. DefaultIdleTimeout = 60 * time.Second )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ByteRange ¶
ByteRange is an inclusive HTTP byte range.
func (ByteRange) HeaderValue ¶
HeaderValue returns the value for an HTTP Range header.
type Options ¶
type Options struct {
// PartSize is the maximum byte count requested per range. Zero selects
// DefaultPartSize.
PartSize int64
// MaxResponses bounds the total responses in one logical stream. Zero derives
// a bound from the declared object size and PartSize.
MaxResponses int
// MaxPartRetries bounds retries per range. Zero selects the default.
MaxPartRetries int
// RetryDelay is the base exponential backoff. Zero selects the default.
RetryDelay time.Duration
// RetryWaitBudget bounds cumulative retry sleeps. Zero selects the default.
RetryWaitBudget time.Duration
// IdleTimeout bounds waiting for response headers or one body read. Time
// between caller reads does not count. Zero selects the default.
IdleTimeout time.Duration
// DisableMultipart forces one full response.
DisableMultipart bool
// contains filtered or unexported fields
}
Options controls multipart behavior. Zero values select production defaults.
type Representation ¶
type Representation string
Representation declares whether repeated range requests are guaranteed to address the same bytes.
const ( // Mutable requires a strong ETag before Open combines multiple responses. Mutable Representation = "mutable" // Immutable permits multipart reads without an ETag because the caller // guarantees that the source identifier pins one representation. Immutable Representation = "immutable" )
type Source ¶
type Source struct {
// contains filtered or unexported fields
}
Source binds a transport to its representation stability.
func ImmutableSource ¶
ImmutableSource allows multipart reads without a validator.
func MutableSource ¶
MutableSource requires a strong ETag before combining responses.
type Stream ¶
type Stream struct {
// Body joins all validated parts and must be closed by the caller.
Body io.ReadCloser
// Header is a copy of the first successful response headers.
Header http.Header
// ContentLength is the validated total size, or -1 when unknown.
ContentLength int64
// contains filtered or unexported fields
}
Stream is one logical full or multipart response.