Documentation ¶
Overview ¶
Package download provides a library to handle file download requests.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ErrNoOverlap = errors.New("invalid range: failed to overlap")
ErrNoOverlap is returned by serveContent's parseRange if first-byte-pos of all of the byte-range-spec values is greater than the content size.
var ErrSeeker = errors.New("seeker can't seek")
ErrSeeker is returned by ServeContent's sizeFunc when the content doesn't seek properly. The underlying Seeker's error text isn't included in the sizeFunc reply so it's not sent over HTTP to end users.
Functions ¶
func GetOrHeadFile ¶
GetOrHeadFile returns the requested file content
func RangesMIMESize ¶
RangesMIMESize returns the number of bytes it takes to encode the provided ranges as a multipart response.
func SumRangesSize ¶
SumRangesSize adds up the length of all ranges
Types ¶
type HTTPRange ¶
type HTTPRange struct {
Start, Length int64
}
HTTPRange specifies the byte range to be sent to the client.
func ParseRange ¶
ParseRange parses a Range header string as per RFC 7233. errNoOverlap is returned if none of the ranges overlap.
func (HTTPRange) ContentRange ¶
ContentRange formats a Range header string as per RFC 7233.
func (HTTPRange) MimeHeader ¶
func (r HTTPRange) MimeHeader(contentType string, size int64) textproto.MIMEHeader
MimeHeader creates range relevant MimeHeaders