http

package
v2.1.0-alpha.1 Latest Latest
Warning

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

Go to latest
Published: Mar 28, 2023 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// RangePrefix is prefix of range header.
	RangePrefix = "bytes="

	// RangeSeparator is separator of range header.
	RangeSeparator = "-"
)

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 HeaderToMap

func HeaderToMap(header http.Header) map[string]string

HeaderToMap coverts request headers to map[string]string.

func MapToHeader

func MapToHeader(m map[string]string) http.Header

MapToHeader coverts map[string]string to request headers.

func PickHeader

func PickHeader(header http.Header, key, defaultValue string) string

PickHeader pick header with key.

Types

type Range

type Range struct {
	Start, Length int64
}

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

func MustParseRange added in v2.0.9

func MustParseRange(s string, size int64) Range

MustParseRange is like ParseRange but panics if the range cannot be parsed.

func ParseOneRange added in v2.0.9

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

ParseOneRange parses only one range of Range header string as per RFC 7233.

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 ParseURLMetaRange added in v2.0.9

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

ParseRange parses a Range string of grpc UrlMeta. Example:

"Range": "100-200"
"Range": "-50"
"Range": "150-"

func (*Range) String

func (r *Range) String() string

String specifies the string of http header.

func (*Range) URLMetaString added in v2.0.9

func (r *Range) URLMetaString() string

String specifies the string of url meta.

Jump to

Keyboard shortcuts

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