httpranger

package
v0.0.0-...-9815a85 Latest Latest
Warning

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

Go to latest
Published: Apr 25, 2024 License: MIT Imports: 19 Imported by: 3

Documentation

Overview

Package httpranger implements lazy io.Reader and io.Writer interfaces.

Index

Constants

This section is empty.

Variables

View Source
var ErrInvalidRange = errs.Class("invalid range")

ErrInvalidRange is an error returned when an invalid HTTP range is requested.

View Source
var Error = errs.Class("ranger")

Error is the errs class of standard Ranger errors.

Functions

func HTTPRanger

func HTTPRanger(ctx context.Context, url string) (_ ranger.Ranger, err error)

HTTPRanger turns an HTTP URL into a Ranger.

func HTTPRangerSize

func HTTPRangerSize(url string, size int64) ranger.Ranger

HTTPRangerSize creates an HTTPRanger with known size. Use it if you know the content size. This will safe the extra HEAD request for retrieving the content size.

func ServeContent

func ServeContent(ctx context.Context, w http.ResponseWriter, r *http.Request, name string, modtime time.Time, content ranger.Ranger) (err error)

ServeContent is the Go standard library's http.ServeContent but modified to work with Rangers.

Types

type HTTPRange

type HTTPRange struct {
	Start, Length int64
}

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

func ParseRange

func ParseRange(s string, size int64) ([]HTTPRange, error)

ParseRange parses a Range header string as per RFC 2616. errNoOverlap is returned if none of the ranges overlap.

Jump to

Keyboard shortcuts

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