httpencoding

package
v0.0.0-...-51c7e80 Latest Latest
Warning

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

Go to latest
Published: Apr 13, 2022 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	EncodingZstd     = "zstd"
	EncodingIdentity = "identity"
	EncodingDeflate  = "deflate"
	EncodingGzip     = "gzip"
	EncodingBrotli   = "br"
)

Variables

This section is empty.

Functions

func AcceptEncoding

func AcceptEncoding(from string, to string) (choose string, err error)

func AcceptEncodingWriter

func AcceptEncodingWriter(w http.ResponseWriter, r *http.Request) io.WriteCloser

AcceptEncodingWriter will handle request Accept-Encoding header, set corresponding Content-Encoding header. Caller must call Close() on the returned writer to flush the data.

func ContentEncodingReadAll

func ContentEncodingReadAll(resp *http.Response) ([]byte, error)

func ContentEncodingReader

func ContentEncodingReader(resp *http.Response) (r io.Reader, err error)

func IsSupported

func IsSupported(name string) bool

func NewReader

func NewReader(enc string, r io.Reader) (io.ReadCloser, error)

func NewWriter

func NewWriter(enc string, w io.Writer) (out io.WriteCloser, err error)

func RegisterEncoding

func RegisterEncoding(name string, c *Encoding)

func Transfer

func Transfer(from string, in io.Reader, to string, out io.Writer) (int64, error)

func TransferBytes

func TransferBytes(from string, in []byte, to string) ([]byte, error)

Types

type Encoding

type Encoding struct {
	Name      string
	NewReader func(r io.Reader) (io.ReadCloser, error)
	NewWriter func(w io.Writer) (io.WriteCloser, error)
}

func (*Encoding) DecodeBytes

func (c *Encoding) DecodeBytes(in []byte) (out []byte, err error)

func (*Encoding) EncodeBytes

func (c *Encoding) EncodeBytes(in []byte) (out []byte, err error)

Jump to

Keyboard shortcuts

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