coding

package
v1.18.3 Latest Latest
Warning

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

Go to latest
Published: Dec 2, 2026 License: Apache-2.0 Imports: 7 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package coding undoes HTTP content codings, the values of a Content-Encoding header (RFC 9110, section 8.4.1).

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrUnsupported means the content coding is not identity, none or gzip.
	ErrUnsupported = errors.New("unsupported content coding")
	// ErrHeader means a gzip body does not start with a valid gzip header.
	ErrHeader = errors.New("invalid gzip header")
	// ErrTooLarge means the decoded body is over the limit.
	ErrTooLarge = errors.New("decoded body exceeds the limit")
)

Functions

func Decode

func Decode(data []byte, enc string, limit int64) ([]byte, error)

Decode undoes the content coding enc, matched without regard to case. It returns nil and no error when data is empty, or when enc is empty, identity or none, so the caller keeps data as it is. Only gzip is decoded. A decoded body over limit bytes returns ErrTooLarge, and a limit of 0 or less means no limit. Gzip data that breaks off returns the compress/gzip error.

func NewReader added in v1.18.1

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

NewReader returns a reader that decodes r, or nil when enc names no coding.

Types

This section is empty.

Jump to

Keyboard shortcuts

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