Documentation ¶
Index ¶
- Constants
- func CharsetOf(str string) string
- func ParamOf(str, key string) string
- func ParamOfOr(str, key, or string) string
- func QualityOf(str string) int
- func ValueOf(str string) string
- type Encoding
- type Headers
- func (h *Headers) Add(key, value string)
- func (h *Headers) Clear()
- func (h *Headers) Get(key string) (string, bool)
- func (h *Headers) Has(key string) bool
- func (h *Headers) Iter() iter.Iterator[[]string]
- func (h *Headers) Keys() []string
- func (h *Headers) KeysIter() iter.Iterator[string]
- func (h *Headers) Unwrap() []string
- func (h *Headers) Value(key string) string
- func (h *Headers) ValueOr(key, or string) string
- func (h *Headers) Values(key string) (values []string)
- func (h *Headers) ValuesIter(key string) iter.Iterator[string]
Constants ¶
const DefaultEncoding = "iso-8859-1"
Variables ¶
This section is empty.
Functions ¶
func CharsetOf ¶
CharsetOf returns a charset parameter value, returning DefaultEncoding in case not presented
func ParamOf ¶
ParamOf is an alias to ParamOfOr, except no `or`-parameter is passed - empty string will be returned in case not found.
func ParamOfOr ¶
ParamOfOr looks for a parameter in a value, and if found, returns a parameter value. In case parameter is not found, `or` is returned
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 FromMap ¶ added in v0.9.3
FromMap returns headers instance with already inserted values from given map. Note: as maps are unordered, resulting Headers instance will also contain unordered pairs (but guaranteed to be grouped together)
func NewPreallocHeaders ¶ added in v0.9.3
NewPreallocHeaders returns empty Headers instance with pre-allocated storage for exactly n pairs (two different values of a single header are also counted as two pairs)
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
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) Iter ¶ added in v0.9.2
Iter returns an iterator over all the header key-value pairs (each pair is exactly 2 values). Note: these pairs aren't sorted nor unique, so multiple Constant-Header: <some value> pairs may have any other pairs between
func (*Headers) Unwrap ¶
Unwrap returns an underlying map as it is. This means that modifying it will also affect Headers object
func (*Headers) Value ¶
Value does the same as ValueOr does but returning an empty string by default