httputil

package
v5.5.0 Latest Latest
Warning

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

Go to latest
Published: Dec 1, 2024 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type HeaderValue

type HeaderValue struct {
	Value    string
	Priority float64
}

HeaderValue represent a value and its quality value (priority) in a multi-values HTTP header.

func ParseMultiValuesHeader

func ParseMultiValuesHeader(header string) []HeaderValue

ParseMultiValuesHeader parses multi-values HTTP headers, taking the quality values into account. The result is a slice of values sorted according to the order of priority.

The input is trimmed. If the input is empty, returns an empty slice.

See: https://developer.mozilla.org/en-US/docs/Glossary/Quality_values

For the following header:

"text/html,text/*;q=0.5,*/*;q=0.7"

returns

[{text/html 1} {*/* 0.7} {text/* 0.5}]

Jump to

Keyboard shortcuts

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