byterange

package
v1.1.5 Latest Latest
Warning

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

Go to latest
Published: Feb 4, 2021 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Overview

Package byterange provides acceleration functions for Byte Ranges for use with HTTP Range Requests

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ParseMultipartRangeResponseBody

func ParseMultipartRangeResponseBody(body io.Reader,
	contentTypeHeader string) (MultipartByteRanges, string, Ranges, int64, error)

ParseMultipartRangeResponseBody returns a MultipartByteRanges from the provided body

Types

type MultipartByteRange

type MultipartByteRange struct {
	Range   Range  `msg:"range"`
	Content []byte `msg:"content"`
}

MultipartByteRange represents one part of a list of multipart byte ranges

func (*MultipartByteRange) DecodeMsg

func (z *MultipartByteRange) DecodeMsg(dc *msgp.Reader) (err error)

DecodeMsg implements msgp.Decodable

func (*MultipartByteRange) EncodeMsg

func (z *MultipartByteRange) EncodeMsg(en *msgp.Writer) (err error)

EncodeMsg implements msgp.Encodable

func (*MultipartByteRange) MarshalMsg

func (z *MultipartByteRange) MarshalMsg(b []byte) (o []byte, err error)

MarshalMsg implements msgp.Marshaler

func (*MultipartByteRange) Msgsize

func (z *MultipartByteRange) Msgsize() (s int)

Msgsize returns an upper bound estimate of the number of bytes occupied by the serialized message

func (*MultipartByteRange) UnmarshalMsg

func (z *MultipartByteRange) UnmarshalMsg(bts []byte) (o []byte, err error)

UnmarshalMsg implements msgp.Unmarshaler

type MultipartByteRanges

type MultipartByteRanges map[Range]*MultipartByteRange

MultipartByteRanges is a list of type MultipartByteRange

func (MultipartByteRanges) Body

func (mbrs MultipartByteRanges) Body(fullContentLength int64, contentType string) (http.Header, []byte)

Body returns http headers and body representing the subject MultipartByteRanges map, which is suitable for responding to an HTTP request for the full cached range

func (MultipartByteRanges) Compress

func (mbrs MultipartByteRanges) Compress()

Compress will take a Multipart Byte Range Map and compress it such that adajecent ranges are merged

func (MultipartByteRanges) ExtractResponseRange

func (mbrs MultipartByteRanges) ExtractResponseRange(ranges Ranges, fullContentLength int64,
	contentType string, body []byte) (http.Header, []byte)

ExtractResponseRange returns http headers and body representing the subject MultipartByteRanges map, cropped to the provided ranges

func (MultipartByteRanges) Merge

func (mbrs MultipartByteRanges) Merge(src MultipartByteRanges)

Merge merges the source MultipartByteRanges map into the subject map

func (MultipartByteRanges) PackableMultipartByteRanges

func (mbrs MultipartByteRanges) PackableMultipartByteRanges() map[string]*MultipartByteRange

PackableMultipartByteRanges returns a version of the subject MultipartByteRanges map that is packable by most marshallers, which may require that maps have a key type of string

func (MultipartByteRanges) Ranges

func (mbrs MultipartByteRanges) Ranges() Ranges

Ranges returns a Ranges object from the MultipartByteRanges Object

type Range

type Range struct {
	Start int64 `msg:"start"`
	End   int64 `msg:"end"`
}

Range represents the start and end for a byte range object

func ParseContentRangeHeader

func ParseContentRangeHeader(input string) (Range, int64, error)

ParseContentRangeHeader returns a Ranges list from the provided input, which must be a properly-formatted HTTP 'Content-Range' Response Header value

func (Range) ContentRangeHeader

func (br Range) ContentRangeHeader(contentLength int64) string

ContentRangeHeader returns a 'Content-Range' header representing the extent of the subject range

func (*Range) DecodeMsg

func (z *Range) DecodeMsg(dc *msgp.Reader) (err error)

DecodeMsg implements msgp.Decodable

func (Range) EncodeMsg

func (z Range) EncodeMsg(en *msgp.Writer) (err error)

EncodeMsg implements msgp.Encodable

func (Range) Less

func (br Range) Less(br2 Range) bool

Less returns true if element i in the Ranges comes before j

func (Range) MarshalMsg

func (z Range) MarshalMsg(b []byte) (o []byte, err error)

MarshalMsg implements msgp.Marshaler

func (Range) Msgsize

func (z Range) Msgsize() (s int)

Msgsize returns an upper bound estimate of the number of bytes occupied by the serialized message

func (Range) String

func (br Range) String() string

func (*Range) UnmarshalMsg

func (z *Range) UnmarshalMsg(bts []byte) (o []byte, err error)

UnmarshalMsg implements msgp.Unmarshaler

type Ranges

type Ranges []Range

Ranges represents a slice of type Range The objects in the slice may not overlap value coverage, meaning values are contained within <= 1 Range in the slice Good: [ 1-10, 21-30, 35-40 ]; Bad: [ 1-10, 10-20 ]; Bad: [ 1-10, 5-20 ]

func ParseRangeHeader

func ParseRangeHeader(input string) Ranges

ParseRangeHeader returns a Ranges list from the provided input, which must be a properly-formatted HTTP 'Range' Request Header value

func (Ranges) CalculateDelta

func (brs Ranges) CalculateDelta(haves Ranges, fullContentLength int64) Ranges

CalculateDelta calculates the delta between two Ranges

func (*Ranges) DecodeMsg

func (z *Ranges) DecodeMsg(dc *msgp.Reader) (err error)

DecodeMsg implements msgp.Decodable

func (Ranges) EncodeMsg

func (z Ranges) EncodeMsg(en *msgp.Writer) (err error)

EncodeMsg implements msgp.Encodable

func (Ranges) Equal

func (brs Ranges) Equal(brs2 Ranges) bool

Equal returns true if the compared byte range slices are equal and assumes that the Ranges are sorted

func (Ranges) Len

func (brs Ranges) Len() int

Len returns the length of an slice of type Ranges

func (Ranges) Less

func (brs Ranges) Less(i, j int) bool

Less returns true if element i in the Ranges comes before j

func (Ranges) MarshalMsg

func (z Ranges) MarshalMsg(b []byte) (o []byte, err error)

MarshalMsg implements msgp.Marshaler

func (Ranges) Msgsize

func (z Ranges) Msgsize() (s int)

Msgsize returns an upper bound estimate of the number of bytes occupied by the serialized message

func (Ranges) String

func (brs Ranges) String() string

func (Ranges) Swap

func (brs Ranges) Swap(i, j int)

Swap modifies an Ranges by swapping the values in indexes i and j

func (*Ranges) UnmarshalMsg

func (z *Ranges) UnmarshalMsg(bts []byte) (o []byte, err error)

UnmarshalMsg implements msgp.Unmarshaler

Jump to

Keyboard shortcuts

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