http_range

package
v3.28.0 Latest Latest
Warning

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

Go to latest
Published: Sep 22, 2023 License: AGPL-3.0 Imports: 6 Imported by: 12

Documentation

Overview

Package http_range implements http range parsing.

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrNoOverlap is returned by ParseRange if first-byte-pos of
	// all the byte-range-spec values is greater than the content size.
	ErrNoOverlap = errors.New("invalid range: failed to overlap")

	// ErrInvalid is returned by ParseRange on invalid input.
	ErrInvalid = errors.New("invalid range")
)

Functions

func ApplyRangeToHttpHeader added in v3.25.0

func ApplyRangeToHttpHeader(p Range, headerRef http.Header) http.Header

ApplyRangeToHttpHeader for http request header

func ParseContentRange added in v3.28.0

func ParseContentRange(s string) (start, end int64, err error)

ParseContentRange this function parse content-range in http response

Types

type Range

type Range struct {
	Start  int64
	Length int64 // limit of bytes to read, -1 for unlimited
}

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

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. ErrInvalid is returned if s is invalid range.

func (Range) ContentRange

func (r Range) ContentRange(size int64) string

ContentRange returns Content-Range header value.

func (Range) MimeHeader added in v3.25.0

func (r Range) MimeHeader(contentType string, size int64) textproto.MIMEHeader

Jump to

Keyboard shortcuts

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