header

package
v1.9.0 Latest Latest
Warning

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

Go to latest
Published: Sep 24, 2026 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsCookie added in v1.5.0

func IsCookie(name string) bool

func Key

func Key(name string) (string, error)

Key returns the case-insensitive identity of a valid header name.

func Present

func Present(src map[string][]string, name string) bool

Present reports whether name carries a non-blank value in src.

func Sensitive added in v1.5.0

func Sensitive(name string) bool

func Valid

func Valid(name string) bool

Valid reports whether name is an HTTP field-name token. Whitespace is never trimmed: callers must decide whether trimming belongs at their own boundary.

func Value

func Value(src map[string][]string, name string) string

Value returns the first non-blank value stored under name. Keys are matched case-insensitively and are never canonicalized, so a block written straight into the map answers the same way one built with the http.Header setters does.

Types

type CollisionError

type CollisionError struct {
	First  string
	Second string
}

CollisionError reports header names with the same case-insensitive identity.

func (*CollisionError) Error

func (e *CollisionError) Error() string

type Name

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

Name is a validated, case-insensitive HTTP field name. Its zero value is not a valid name.

func Parse

func Parse(name string) (Name, error)

Parse validates name and returns its case-insensitive identity.

func (Name) Key

func (n Name) Key() string

Key returns the normalized identity of n.

type NameError

type NameError struct {
	Name string
}

NameError reports a string that is not an HTTP field name.

func (*NameError) Error

func (e *NameError) Error() string

type Named

type Named struct {
	Source string
	Name   Name
}

Named contains a header name and its case-insensitive identity.

func Keys

func Keys[V any](src map[string]V) ([]Named, error)

Keys validates and sorts the names in src. It rejects names with the same case-insensitive identity so map iteration cannot choose which value wins. Sorting also makes validation errors deterministic.

type Set added in v1.5.0

type Set map[string]struct{}

func NewSet added in v1.5.0

func NewSet(names ...string) Set

func (Set) Add added in v1.5.0

func (s Set) Add(names ...string)

func (Set) Has added in v1.5.0

func (s Set) Has(name string) bool

type Values

type Values map[string][]string

Values is a header block. Every entry is represented as a list, including entries with zero or one value.

func Normalize

func Normalize(src map[string][]string) (Values, error)

Normalize validates names, rejects equivalent forms, copies every value list, and keys the result by header identity.

Jump to

Keyboard shortcuts

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