mime

package
v0.13.0 Latest Latest
Warning

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

Go to latest
Published: Jan 20, 2025 License: MIT Imports: 21 Imported by: 0

Documentation

Index

Constants

View Source
const (
	EncodingGzip     = "gzip"
	EncodingDeflate  = "deflate"
	EncodingBr       = "br"
	EncodingIdentity = "identity"
)
View Source
const (
	HeaderAccept                  = "Accept"
	HeaderAcceptCharset           = "Accept-Charset"
	HeaderAcceptEncoding          = "Accept-Encoding"
	HeaderAcceptLanguage          = "Accept-Language"
	HeaderAllow                   = "Allow"
	HeaderAuthorization           = "Authorization"
	HeaderContentDisposition      = "Content-Disposition"
	HeaderContentEncoding         = "Content-Encoding"
	HeaderContentLength           = "Content-Length"
	HeaderContentType             = "Content-Type"
	HeaderCookie                  = "Cookie"
	HeaderSetCookie               = "Set-Cookie"
	HeaderIfModifiedSince         = "If-Modified-Since"
	HeaderLastModified            = "Last-Modified"
	HeaderLocation                = "Location"
	HeaderRetryAfter              = "Retry-After"
	HeaderUpgrade                 = "Upgrade"
	HeaderUpgradeInsecureRequests = "Upgrade-Insecure-Requests"
	HeaderVary                    = "Vary"
	HeaderWWWAuthenticate         = "WWW-Authenticate"
	HeaderForwarded               = "Forwarded"
	HeaderXForwardedFor           = "X-Forwarded-For"
	HeaderXForwardedHost          = "X-Forwarded-Host"
	HeaderXForwardedProto         = "X-Forwarded-Proto"
	HeaderXForwardedProtocol      = "X-Forwarded-Protocol"
	HeaderXForwardedSsl           = "X-Forwarded-Ssl"
	HeaderXUrlScheme              = "X-Url-Scheme"
	HeaderXHTTPMethodOverride     = "X-HTTP-Method-Override"
	HeaderXRealIP                 = "X-Real-Ip"
	HeaderXRequestID              = "X-Request-Id"
	HeaderXCorrelationID          = "X-Correlation-Id"
	HeaderXRequestedWith          = "X-Requested-With"
	HeaderServer                  = "Server"
	HeaderOrigin                  = "Origin"
	HeaderCacheControl            = "Cache-Control"
	HeaderConnection              = "Connection"
	HeaderDate                    = "Date"
	HeaderDeviceMemory            = "Device-Memory"
	HeaderDNT                     = "DNT"
	HeaderDownlink                = "Downlink"
	HeaderDPR                     = "DPR"
	HeaderEarlyData               = "Early-Data"
	HeaderECT                     = "ECT"
	HeaderExpect                  = "Expect"
	HeaderExpectCT                = "Expect-CT"
	HeaderFrom                    = "From"
	HeaderHost                    = "Host"
	HeaderIfMatch                 = "If-Match"
	HeaderIfNoneMatch             = "If-None-Match"
	HeaderIfRange                 = "If-Range"
	HeaderIfUnmodifiedSince       = "If-Unmodified-Since"
	HeaderKeepAlive               = "Keep-Alive"
	HeaderMaxForwards             = "Max-Forwards"
	HeaderProxyAuthorization      = "Proxy-Authorization"
	HeaderRange                   = "Range"
	HeaderReferer                 = "Referer"
	HeaderRTT                     = "RTT"
	HeaderSaveData                = "Save-Data"
	HeaderTE                      = "TE"
	HeaderTk                      = "Tk"
	HeaderTrailer                 = "Trailer"
	HeaderTransferEncoding        = "Transfer-Encoding"
	HeaderUserAgent               = "User-Agent"
	HeaderVia                     = "Via"
	HeaderViewportWidth           = "Viewport-Width"
	HeaderWantDigest              = "Want-Digest"
	HeaderWarning                 = "Warning"
	HeaderWidth                   = "Width"

	HeaderAccessControlRequestMethod    = "Access-Control-Request-Method"
	HeaderAccessControlRequestHeaders   = "Access-Control-Request-Headers"
	HeaderAccessControlAllowOrigin      = "Access-Control-Allow-Origin"
	HeaderAccessControlAllowMethods     = "Access-Control-Allow-Methods"
	HeaderAccessControlAllowHeaders     = "Access-Control-Allow-Headers"
	HeaderAccessControlAllowCredentials = "Access-Control-Allow-Credentials"
	HeaderAccessControlExposeHeaders    = "Access-Control-Expose-Headers"
	HeaderAccessControlMaxAge           = "Access-Control-Max-Age"

	HeaderStrictTransportSecurity         = "Strict-Transport-Security"
	HeaderXContentTypeOptions             = "X-Content-Type-Options"
	HeaderXXSSProtection                  = "X-XSS-Protection"
	HeaderXFrameOptions                   = "X-Frame-Options"
	HeaderContentSecurityPolicy           = "Content-Security-Policy"
	HeaderContentSecurityPolicyReportOnly = "Content-Security-Policy-Report-Only"
	HeaderXCSRFToken                      = "X-CSRF-Token"
	HeaderReferrerPolicy                  = "Referrer-Policy"
)
View Source
const (
	ApplicationJSON                  = "application/json"
	ApplicationJSONCharsetUTF8       = ApplicationJSON + "; " + charsetUTF8
	ApplicationJavaScript            = "application/javascript"
	ApplicationJavaScriptCharsetUTF8 = ApplicationJavaScript + "; " + charsetUTF8
	ApplicationXML                   = "application/xml"
	ApplicationXMLCharsetUTF8        = ApplicationXML + "; " + charsetUTF8
	ApplicationOctetStream           = "application/octet-stream"
	TextXML                          = "text/xml"
	TextXMLCharsetUTF8               = TextXML + "; " + charsetUTF8
	ApplicationFormURLEncoded        = "application/x-www-form-urlencoded"
	ApplicationProtobuf              = "application/protobuf"
	ApplicationMsgpack               = "application/msgpack"
	TextHTML                         = "text/html"
	TextHTMLCharsetUTF8              = TextHTML + "; " + charsetUTF8
	TextPlain                        = "text/plain"
	TextPlainCharsetUTF8             = TextPlain + "; " + charsetUTF8
	MultipartFormData                = "multipart/form-data"
)

Variables

This section is empty.

Functions

func Compress

func Compress(writer io.Writer, encoding string) (io.Writer, error)

Compress compresses input data using the specified encoding, returns original if unsupported.

func Decode

func Decode(reader io.Reader, header textproto.MIMEHeader) (types.Value, error)

Decode decodes the given reader with the specified MIME headers into types.

func Decompress

func Decompress(reader io.Reader, encoding string) (io.Reader, error)

Decompress decompresses input data using the specified encoding, returns original if unsupported.

func DetectTypesFromBytes added in v0.12.0

func DetectTypesFromBytes(value []byte) []string

DetectTypesFromBytes determines the potential content types of the given byte slice.

func DetectTypesFromValue added in v0.12.0

func DetectTypesFromValue(value types.Value) []string

DetectTypesFromValue determines the content types based on the type of types passed.

func Encode

func Encode(writer io.Writer, value types.Value, header textproto.MIMEHeader) error

Encode encodes the given types into the writer with the specified MIME headers.

func IsCompatible

func IsCompatible(x, y string) bool

IsCompatible checks if two media types are compatible.

func IsResponseHeader

func IsResponseHeader(header string) bool

func Negotiate

func Negotiate(value string, offers []string) string

Negotiate determines the best media type from the given value and offers based on quality factors. If offers is nil, it returns the first valid media type found in the value.

Types

This section is empty.

Jump to

Keyboard shortcuts

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