Documentation ¶
Index ¶
Constants ¶
const ( // RangePrefix is prefix of range header. RangePrefix = "bytes=" // RangeSeparator is separator of range header. RangeSeparator = "-" )
Variables ¶
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 ¶
HeaderToMap coverts request headers to map[string]string.
func MapToHeader ¶
MapToHeader coverts map[string]string to request headers.
Types ¶
type Range ¶
type Range struct {
Start, Length int64
}
Range specifies the byte range to be sent to the client.
func MustParseRange ¶
MustParseRange is like ParseRange but panics if the range cannot be parsed.
func ParseOneRange ¶
ParseOneRange parses only one range of Range header string as per RFC 7233.
func ParseRange ¶
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 ¶
ParseRange parses a Range string of grpc UrlMeta. Example:
"Range": "100-200" "Range": "-50" "Range": "150-"
func (*Range) URLMetaString ¶
String specifies the string of url meta.