qpack

package module
v0.6.0 Latest Latest
Warning

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

Go to latest
Published: Nov 17, 2025 License: MIT Imports: 4 Imported by: 71

README

QPACK

PkgGoDev Code Coverage Fuzzing Status

This is a minimal QPACK (RFC 9204) implementation in Go. It reuses the Huffman encoder / decoder code from the HPACK implementation in the Go standard library.

It is fully interoperable with other QPACK implementations (both encoders and decoders). However, it does not support the dynamic table and relies solely on the static table and string literals (including Huffman encoding), which limits compression efficiency. If you're interested in dynamic table support, please comment on issue #33.

Running the Interop Tests

Install the QPACK interop files by running

git submodule update --init --recursive

Then run the tests:

go test -v ./interop

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DecodeFunc added in v0.6.0

type DecodeFunc func() (HeaderField, error)

DecodeFunc is a function that decodes the next header field from a header block. It should be called repeatedly until it returns io.EOF. It returns io.EOF when all header fields have been decoded. Any error other than io.EOF indicates a decoding error.

type Decoder

type Decoder struct{}

A Decoder decodes QPACK header blocks. A Decoder can be reused to decode multiple header blocks on different streams on the same connection (e.g., headers then trailers). This will be useful when dynamic table support is added.

func NewDecoder

func NewDecoder() *Decoder

NewDecoder returns a new Decoder.

func (*Decoder) Decode added in v0.6.0

func (d *Decoder) Decode(p []byte) DecodeFunc

Decode returns a function that decodes header fields from the given header block. It does not copy the slice; the caller must ensure it remains valid during decoding.

type Encoder

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

An Encoder performs QPACK encoding.

func NewEncoder

func NewEncoder(w io.Writer) *Encoder

NewEncoder returns a new Encoder which performs QPACK encoding. An encoded data is written to w.

func (*Encoder) Close

func (e *Encoder) Close() error

Close declares that the encoding is complete and resets the Encoder to be reused again for a new header block.

func (*Encoder) WriteField

func (e *Encoder) WriteField(f HeaderField) error

WriteField encodes f into a single Write to e's underlying Writer. This function may also produce bytes for the Header Block Prefix if necessary. If produced, it is done before encoding f.

type HeaderField

type HeaderField struct {
	Name  string
	Value string
}

A HeaderField is a name-value pair. Both the name and value are treated as opaque sequences of octets.

func (HeaderField) IsPseudo

func (hf HeaderField) IsPseudo() bool

IsPseudo reports whether the header field is an HTTP3 pseudo header. That is, it reports whether it starts with a colon. It is not otherwise guaranteed to be a valid pseudo header field, though.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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