download

package
v0.0.0-...-aac29df Latest Latest
Warning

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

Go to latest
Published: Feb 25, 2020 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CheckETag

func CheckETag(w http.ResponseWriter, r *http.Request, modtime time.Time) (rangeReq string, done bool)

handle ETag CheckETag implements If-None-Match and If-Range checks.

The ETag or modtime must have been previously set in the ResponseWriter's headers. The modtime is only compared at second granularity and may be the zero value to mean unknown.

The return value is the effective request "Range" header to use and whether this request is now considered done.

func CheckLastModified

func CheckLastModified(w http.ResponseWriter, r *http.Request, modifyTime time.Time) bool

检查Last-Modified头。返回true: 请求已经完成了。(言下之意,文件没有修改过) 返回false:文件修改过。

func DownloadFile

func DownloadFile(
	writer http.ResponseWriter,
	request *http.Request,
	filePath string,
	filename string,
	withContentDisposition bool)

file download. https://github.com/Masterminds/go-fileserver

func PanicError

func PanicError(err error)

func RangesMIMESize

func RangesMIMESize(ranges []HttpRange, contentType string, contentSize int64) (encSize int64)

RangesMIMESize returns the number of bytes it takes to encode the provided ranges as a multipart response.

func SumRangesSize

func SumRangesSize(ranges []HttpRange) (size int64)

Types

type CountingWriter

type CountingWriter int64

CountingWriter counts how many bytes have been written to it.

func (*CountingWriter) Write

func (w *CountingWriter) Write(p []byte) (n int, err error)

type HttpRange

type HttpRange struct {
	// contains filtered or unexported fields
}

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.

Jump to

Keyboard shortcuts

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