httputil

package
v0.0.0-...-13d2ada Latest Latest
Warning

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

Go to latest
Published: Jul 14, 2021 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrInvalidFormat = errors.New("invalid range format")

ErrInvalidFormat is returned when it is an invalid range format

View Source
var ErrInvalidRange = errors.New("invalid range")

ErrInvalidRange is returned when it is an invalid range

View Source
var Now = time.Now

Now returns the current time

Functions

func FormatRetryAfter

func FormatRetryAfter(h http.Header, d time.Duration)

FormatRetryAfter formats the `Retry-After` response header

func ParseQuery

func ParseQuery(q url.Values, v interface{}) error

ParseQuery parses the values of v from the HTTP query

func ParseReq

func ParseReq(ctx context.Context, r *http.Request, params interface{}) error

ParseReq parses the request and returns a standard error in case of failure

func ParseRetryAfter

func ParseRetryAfter(h http.Header) (time.Duration, bool)

ParseRetryAfter parses the `Retry-After` header and returns its duration. If it does not exist or can't be parsed, it will return 0. The values returned are guaranteed to greater or equal to 0.

Types

type HTTPRange

type HTTPRange struct {
	Start, End, Size int64
}

func ParseContentRange

func ParseContentRange(s string) (*HTTPRange, error)

ParseContentRange parses the HTTP Content-Range header

e.g. Content-Range: <unit> <range-start>-<range-end>/<size> Content-Range: <unit> <range-start>-<range-end>/* Content-Range: <unit> */<size>

Jump to

Keyboard shortcuts

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