headers

package
v0.9.1 Latest Latest
Warning

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

Go to latest
Published: Sep 4, 2023 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

View Source
const DefaultEncoding = "iso-8859-1"

Variables

This section is empty.

Functions

func CharsetOf

func CharsetOf(str string) string

CharsetOf returns a charset parameter value, returning DefaultEncoding in case not presented

func ParamOf

func ParamOf(str, key string) string

ParamOf is an alias to ParamOfOr, except no `or`-parameter is passed - empty string will be returned in case not found.

func ParamOfOr

func ParamOfOr(str, key, or string) string

ParamOfOr looks for a parameter in a value, and if found, returns a parameter value. In case parameter is not found, `or` is returned

func QualityOf

func QualityOf(str string) int

QualityOf simply returns a value of quality-parameter as an uint8. If not presented or is not a valid integer, 9 is returned

func ValueOf

func ValueOf(str string) string

ValueOf returns a value until first semicolon is met. Even if the value after semicolon is not a parameter, it will anyway be counted as a parameter

Types

type Encoding added in v0.9.0

type Encoding struct {
	// Transfer represents Transfer-Encoding header value, split by comma
	Transfer []string
	// Content represents Content-Encoding header value, split by comma
	Content []string
	// Chunked doesn't belong to any of encodings, as it is still must be processed individually
	Chunked, HasTrailer bool
}

type Headers

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

Headers is a struct that encapsulates headers map from user, allowing only methods

func NewHeaders

func NewHeaders(underlying map[string][]string) *Headers

func (*Headers) Add

func (h *Headers) Add(key, value string)

Add values to the key. In case did not exist, it'll be created

func (*Headers) Clear

func (h *Headers) Clear()

Clear headers map. Is a system method, that is not supposed to be ever called by user

func (*Headers) Get added in v0.8.1

func (h *Headers) Get(key string) (string, bool)

Get behaves just as map lookup. It returns both desired string and bool flag meaning the success of the operation (false=no such key, true=found)

func (*Headers) Has

func (h *Headers) Has(key string) bool

Has returns true or false depending on whether such a key exists

func (*Headers) KeysIter added in v0.6.0

func (h *Headers) KeysIter() Iterator[string]

func (*Headers) Unwrap

func (h *Headers) Unwrap() []string

Unwrap returns an underlying map as it is. This means that modifying it will also affect Headers object

func (*Headers) Value

func (h *Headers) Value(key string) string

Value does the same as ValueOr does but returning an empty string by default

func (*Headers) ValueOr

func (h *Headers) ValueOr(key, or string) string

ValueOr returns a header value

func (*Headers) Values

func (h *Headers) Values(key string) (values []string)

Values returns a slice of values including parameters

func (*Headers) ValuesIter added in v0.6.0

func (h *Headers) ValuesIter(key string) Iterator[string]

type Iterator added in v0.6.0

type Iterator[T any] func() (element T, continue_ bool)

Jump to

Keyboard shortcuts

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