httpcommon

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Sep 19, 2025 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// HeaderOrderKey is a magic key for ResponseWriter.Header map keys
	// that, if present, defines a header order that will be used to
	// write the headers onto wire. The order of the list defined how the headers
	// will be sorted. A defined key goes before an undefined key.
	//
	// This is the only way to specify some order, because maps don't
	// have a a stable iteration order. If no order is given, headers will
	// be sorted lexicographically.
	//
	// According to RFC-2616 it is good practice to send general-header fields
	// first, followed by request-header or response-header fields and ending
	// with entity-header fields.
	HeaderOrderKey = "Header-Order:"

	// PHeaderOrderKey is a magic key for setting http3 pseudo header order.
	// If the header is nil it will use regular GoLang header order.
	// Valid fields are :authority, :method, :path, :scheme, :protocol
	PHeaderOrderKey = "PHeader-Order:"
)

Variables

This section is empty.

Functions

func ReturnSorter

func ReturnSorter(hs *HeaderSorter)

ReturnSorter returns a header sorter to the pool

func SortedKeyValues

func SortedKeyValues(h http.Header, exclude map[string]bool) (kvs []HeaderKeyValues, hs *HeaderSorter)

SortedKeyValues returns h's keys sorted in the returned kvs slice. The HeaderSorter used to sort is also returned, for possible return to headerSorterPool.

func SortedKeyValuesBy

func SortedKeyValuesBy(
	h http.Header,
	order map[string]int,
	exclude map[string]bool,
) (kvs []HeaderKeyValues, hs *HeaderSorter)

SortedKeyValuesBy returns headers sorted by specified order

Types

type HeaderKeyValues

type HeaderKeyValues struct {
	Key    string
	Values []string
}

HeaderKeyValues represents a key-value pair for headers

type HeaderSorter

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

A HeaderSorter implements sort.Interface by sorting a []HeaderKeyValues by key. It's used as a pointer, so it can fit in a sort.Interface interface value without allocation.

func (*HeaderSorter) Len

func (s *HeaderSorter) Len() int

func (*HeaderSorter) Less

func (s *HeaderSorter) Less(i, j int) bool

func (*HeaderSorter) Swap

func (s *HeaderSorter) Swap(i, j int)

Jump to

Keyboard shortcuts

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