utils

package
v0.0.1-alpha4 Latest Latest
Warning

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

Go to latest
Published: Oct 1, 2025 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const ContentLengthKey = contextKey("contentLength")
View Source
const IsCopy = contextKey("isCopy")
View Source
const Origin = contextKey("origin")
View Source
const RangeKey = contextKey("rangeKey")
View Source
const ShowCorrupted = contextKey("showCorrupted")

Variables

This section is empty.

Functions

func CopyWithCtx

func CopyWithCtx(ctx context.Context, dst io.Writer, src io.Reader) (int64, error)

Types

type PathWithArgs

type PathWithArgs struct {
	Path string
	// contains filtered or unexported fields
}

func NewPathWithArgs

func NewPathWithArgs(path string) PathWithArgs

func NewPathWithArgsFromString

func NewPathWithArgsFromString(s string) (PathWithArgs, error)

func (PathWithArgs) FileSize

func (p PathWithArgs) FileSize() (int64, error)

func (PathWithArgs) IsCopy

func (p PathWithArgs) IsCopy() bool

func (PathWithArgs) Origin

func (p PathWithArgs) Origin() string

func (PathWithArgs) Range

func (p PathWithArgs) Range() (*RangeHeader, error)

func (PathWithArgs) SetFileSize

func (p PathWithArgs) SetFileSize(s string)

func (PathWithArgs) SetIsCopy

func (p PathWithArgs) SetIsCopy()

func (PathWithArgs) SetOrigin

func (p PathWithArgs) SetOrigin(origin string)

func (PathWithArgs) SetRange

func (p PathWithArgs) SetRange(r string)

func (PathWithArgs) SetShowCorrupted

func (p PathWithArgs) SetShowCorrupted()

func (PathWithArgs) ShowCorrupted

func (p PathWithArgs) ShowCorrupted() bool

func (PathWithArgs) String

func (p PathWithArgs) String() string

type RangeHeader

type RangeHeader struct {
	Start int64
	End   int64
}

func FixRangeHeader

func FixRangeHeader(rh *RangeHeader, size int64) *RangeHeader

FixRangeHeader looks through the slice of options and adjusts any RangeHeader~s found that request a fetch from the end into an absolute fetch using the size passed in and makes sure the range does not exceed filesize.

func ParseRangeHeader

func ParseRangeHeader(s string) (po *RangeHeader, err error)

ParseRangeHeader parses a RangeHeader from a Range: header. It only accepts single ranges.

func (*RangeHeader) Decode

func (o *RangeHeader) Decode(size int64) (offset, limit int64)

Decode interprets the RangeOption into an offset and a limit

The offset is the start of the stream and the limit is how many bytes should be read from it. If the limit is -1 then the stream should be read to the end.

Jump to

Keyboard shortcuts

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