headers

package
v0.2.21 Latest Latest
Warning

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

Go to latest
Published: Apr 25, 2024 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	AcceptKey         = "Accept"
	AcceptEncodingKey = "Accept-Encoding"
)
View Source
const (
	ContentTypeKey     = "Content-Type"
	ContentLength      = "Content-Length"
	ContentEncodingKey = "Content-Encoding"

	ContentTypeAny ContentType = "*/*"

	TypeApplicationJSON          ContentType = "application/json"
	TypeApplicationXML           ContentType = "application/xml"
	TypeApplicationOctetStream   ContentType = "application/octet-stream"
	TypeApplicationProtobuf      ContentType = "application/protobuf"
	TypeApplicationMsgpack       ContentType = "application/msgpack"
	TypeApplicationXSolomonSpack ContentType = "application/x-solomon-spack"

	EncodingAny     ContentEncoding = "*"
	EncodingZSTD    ContentEncoding = "zstd"
	EncodingLZ4     ContentEncoding = "lz4"
	EncodingGZIP    ContentEncoding = "gzip"
	EncodingDeflate ContentEncoding = "deflate"

	TypeTextPlain    ContentType = "text/plain"
	TypeTextHTML     ContentType = "text/html"
	TypeTextCSV      ContentType = "text/csv"
	TypeTextCmd      ContentType = "text/cmd"
	TypeTextCSS      ContentType = "text/css"
	TypeTextXML      ContentType = "text/xml"
	TypeTextMarkdown ContentType = "text/markdown"

	TypeImageAny  ContentType = "image/*"
	TypeImageJPEG ContentType = "image/jpeg"
	TypeImageGIF  ContentType = "image/gif"
	TypeImagePNG  ContentType = "image/png"
	TypeImageSVG  ContentType = "image/svg+xml"
	TypeImageTIFF ContentType = "image/tiff"
	TypeImageWebP ContentType = "image/webp"

	TypeVideoMPEG ContentType = "video/mpeg"
	TypeVideoMP4  ContentType = "video/mp4"
	TypeVideoOgg  ContentType = "video/ogg"
	TypeVideoWebM ContentType = "video/webm"
)
View Source
const (
	// XYaServiceTicket is http header that should be used for service ticket transfer.
	XYaServiceTicketKey = "X-Ya-Service-Ticket"
	// XYaUserTicket is http header that should be used for user ticket transfer.
	XYaUserTicketKey = "X-Ya-User-Ticket"
)
View Source
const (
	WarningKey = "Warning"

	WarningResponseIsStale                = 110 // RFC 7234, 5.5.1
	WarningRevalidationFailed             = 111 // RFC 7234, 5.5.2
	WarningDisconnectedOperation          = 112 // RFC 7234, 5.5.3
	WarningHeuristicExpiration            = 113 // RFC 7234, 5.5.4
	WarningMiscellaneousWarning           = 199 // RFC 7234, 5.5.5
	WarningTransformationApplied          = 214 // RFC 7234, 5.5.6
	WarningMiscellaneousPersistentWarning = 299 // RFC 7234, 5.5.7
)
View Source
const (
	CookieKey = "Cookie"
)
View Source
const (
	UserAgentKey = "User-Agent"
)

Variables

This section is empty.

Functions

func AddWarning

func AddWarning(h http.Header, warn int, agent, reason string, date time.Time)

AddWarning adds Warning to http.Header with proper formatting see: https://tools.ietf.org/html/rfc7234#section-5.5

func WarningText

func WarningText(warn int) string

WarningText returns a text for the warning header code. It returns the empty string if the code is unknown.

Types

type AcceptableEncoding

type AcceptableEncoding struct {
	Encoding ContentEncoding
	Weight   float32
	// contains filtered or unexported fields
}

type AcceptableEncodings

type AcceptableEncodings []AcceptableEncoding

func ParseAcceptEncoding

func ParseAcceptEncoding(headerValue string) (AcceptableEncodings, error)

ParseAcceptEncoding parses Accept-Encoding HTTP header. It will sort acceptable encodings by weight and position. See: https://tools.ietf.org/html/rfc2616#section-14.3

func (AcceptableEncodings) IsAcceptable

func (as AcceptableEncodings) IsAcceptable(encoding ContentEncoding) bool

func (AcceptableEncodings) String

func (as AcceptableEncodings) String() string

type AcceptableType

type AcceptableType struct {
	Type      ContentType
	Weight    float32
	Extension map[string]string
	// contains filtered or unexported fields
}

type AcceptableTypes

type AcceptableTypes []AcceptableType

func ParseAccept

func ParseAccept(headerValue string) (AcceptableTypes, error)

ParseAccept parses Accept HTTP header. It will sort acceptable types by weight, specificity and position. See: https://tools.ietf.org/html/rfc2616#section-14.1

func (AcceptableTypes) IsAcceptable

func (as AcceptableTypes) IsAcceptable(contentType ContentType) bool

func (AcceptableTypes) String

func (as AcceptableTypes) String() string

type ContentEncoding

type ContentEncoding string

func (ContentEncoding) String

func (ce ContentEncoding) String() string

String implements stringer interface

type ContentType

type ContentType string

func (ContentType) String

func (ct ContentType) String() string

String implements stringer interface

type TokenType

type TokenType string
const (
	AuthorizationKey = "Authorization"

	TokenTypeBearer TokenType = "bearer"
	TokenTypeMAC    TokenType = "mac"
)

func AuthorizationTokenType

func AuthorizationTokenType(token string) TokenType

func (TokenType) String

func (tt TokenType) String() string

String implements stringer interface

type WarningHeader

type WarningHeader struct {
	Code   int
	Agent  string
	Reason string
	Date   time.Time
}

func ParseWarnings

func ParseWarnings(h http.Header) ([]WarningHeader, error)

ParseWarnings reads and parses Warning headers from http.Header

Jump to

Keyboard shortcuts

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