rangecontrol

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Jan 20, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrRangeHeaderNotFound = errors.New("header Range not found")
	ErrInvalidRange        = errors.New("invalid Range header")
)
View Source
var (
	ErrInvalidContentRange = errors.New("invalid Content-Range")
)

Functions

func SortRanges

func SortRanges(ranges []ByteRange)

Types

type ByteRange

type ByteRange struct {
	Start int64 // inclusive
	End   int64 // inclusive, -1 表示 open-ended (100-)
}

func MergeRanges

func MergeRanges(ranges []ByteRange) []ByteRange

func Parse

func Parse(rangeHeader string) ([]ByteRange, error)

Parse parses a Range header and returns.

func (ByteRange) ContentRange

func (r ByteRange) ContentRange(totalSize uint64) string

func (ByteRange) Length

func (r ByteRange) Length() int64

func (ByteRange) MimeHeader

func (r ByteRange) MimeHeader(contentType string, size uint64) textproto.MIMEHeader

func (ByteRange) String

func (r ByteRange) String() string

type ContentRange

type ContentRange struct {
	Start       int64 // >=0, undefined if Unsatisfied
	End         int64 // >=Start
	Size        int64 // total size, -1 if unknown
	Unsatisfied bool  // true for "*/size"
}

func ParseContentRange

func ParseContentRange(header string) (*ContentRange, error)

Jump to

Keyboard shortcuts

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