multipart

package module
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Sep 16, 2021 License: MIT Imports: 10 Imported by: 1

README

multipart

A simple HTTP multipart/byteranges reponse writer.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrClosed = func(err error) error {
	return fmt.Errorf("pipe is closed before writing %s", err)
}

Functions

This section is empty.

Types

type MultipartReader

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

func NewMultipartReader

func NewMultipartReader(src ReadSeekCloser, parts []*Part) (*MultipartReader, error)

func NewMultipartReaderWithBoudary

func NewMultipartReaderWithBoudary(src ReadSeekCloser, parts []*Part, boundary string) (*MultipartReader, error)

func (*MultipartReader) Close

func (mr *MultipartReader) Close() error

func (*MultipartReader) ContentLength

func (mr *MultipartReader) ContentLength() int64

func (*MultipartReader) Read

func (mr *MultipartReader) Read(p []byte) (n int, err error)

func (*MultipartReader) SetOutputHeaders

func (mr *MultipartReader) SetOutputHeaders(val bool)

func (*MultipartReader) Start

func (mr *MultipartReader) Start()

type Part

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

func NewPart

func NewPart(contentType, rangeStart, rangeEnd, fileSize string) *Part

func RangeToParts

func RangeToParts(rangeValue string, respContentType, respFileSize string) ([]*Part, error)

type ReadSeekCloser

type ReadSeekCloser interface {
	io.Reader
	io.Seeker
	io.Closer
}

TODO: this is introduced in Go 1.16

type Transformer

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

func NewTransformer

func NewTransformer(src ReadSeekCloser, parts []*Part) *Transformer

func NewTransformerWithBoundary

func NewTransformerWithBoundary(src ReadSeekCloser, parts []*Part, boundary string) *Transformer

func (*Transformer) ContentLength

func (tfm *Transformer) ContentLength() int64

func (*Transformer) SetBoundary

func (tfm *Transformer) SetBoundary(boundary string)

func (*Transformer) WriteMultiParts

func (tfm *Transformer) WriteMultiParts(wt io.Writer) error

func (*Transformer) WritePartHeader

func (tfm *Transformer) WritePartHeader(buf io.Writer, part *Part) error

Jump to

Keyboard shortcuts

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