rangecontrol

package
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: Jun 24, 2026 License: MIT Imports: 6 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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