util

package
v2.0.8-rc.2 Latest Latest
Warning

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

Go to latest
Published: Nov 25, 2022 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrNoOverlap = errors.New("invalid range: failed to overlap")

ErrNoOverlap is returned by ParseRange if first-byte-pos of all of the byte-range-spec values is greater than the content size.

Functions

func GetContentRange

func GetContentRange(start, end, total int64) string

Example:

"Content-Range": "bytes 100-200/1000"
"Content-Range": "bytes 100-200/*"

Types

type Duration

type Duration struct {
	time.Duration
}

func (*Duration) UnmarshalJSON

func (d *Duration) UnmarshalJSON(b []byte) error

func (*Duration) UnmarshalYAML

func (d *Duration) UnmarshalYAML(node *yaml.Node) error

type KeepAlive

type KeepAlive interface {
	Keep()
	Alive(alive time.Duration) bool
}

func NewKeepAlive

func NewKeepAlive(name string) KeepAlive

type Range

type Range struct {
	Start, Length int64
}

Range specifies the byte range to be sent to the client.

func MustParseRange

func MustParseRange(s string, size int64) Range

func ParseOneRange added in v2.0.7

func ParseOneRange(s string, size int64) (Range, error)

func ParseRange

func ParseRange(s string, size int64) ([]Range, error)

ParseRange parses a Range header string as per RFC 7233. ErrNoOverlap is returned if none of the ranges overlap. Example:

"Range": "bytes=100-200"
"Range": "bytes=-50"
"Range": "bytes=150-"
"Range": "bytes=0-0,-1"

copy from go/1.15.2 net/http/fs.go ParseRange

func (Range) String

func (r Range) String() string

type RateLimit

type RateLimit struct {
	rate.Limit
}

RateLimit is a wrapper for rate.Limit, support json and yaml unmarshal function yaml example 1: rate_limit: 2097152 # 2MiB yaml example 2: rate_limit: 2MiB

func (*RateLimit) UnmarshalJSON

func (r *RateLimit) UnmarshalJSON(b []byte) error

func (*RateLimit) UnmarshalYAML

func (r *RateLimit) UnmarshalYAML(node *yaml.Node) error

type Size added in v2.0.5

type Size = RateLimit

Directories

Path Synopsis
Package mocks is a generated GoMock package.
Package mocks is a generated GoMock package.

Jump to

Keyboard shortcuts

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