internal/mediatype
import "github.com/gofiber/fiber/v3/internal/mediatype"
Package mediatype parses media types and their parameters (RFC 9110 Section 8.3.1), and canonicalizes the case-insensitive parts of a request's Content-Type, so the case-sensitive parsers downstream — fasthttp's form and multipart readers above all — see the value they expect.
Constants
MaxContentCodings is the longest Content-Encoding list Ctx.Body undoes; curl stops at five as well.
Source: internal/mediatype/mediatype.go:107
const MaxContentCodings = 5Functions
func FormCodingAgrees(h *fasthttp.RequestHeader) bool
Source: internal/mediatype/mediatype.go:112
FormCodingAgrees reports whether fasthttp's form readers take the form from the bytes Ctx.Body returns. Body undoes every coding on every Content-Encoding line, at most MaxContentCodings members counting identity; PostArgs undoes none, MultipartForm only a gzip on the first line.
func IsEventStream(ct []byte) bool
Source: internal/mediatype/mediatype.go:281
IsEventStream reports whether ct is text/event-stream, parameters ignored.
func IsForm(ct []byte) bool
Source: internal/mediatype/mediatype.go:90
IsForm reports whether ct names one of the two media types fasthttp's form parsers handle. Callers gate NormalizeRequestContentType on it, since the fold lands on the request's own bytes. Compared folded, parameters ignored.
func IsToken(b []byte) bool
Source: internal/mediatype/mediatype.go:159
IsToken reports whether b is a token (RFC 9110 Section 5.6.2): one or more tchar.
func NormalizeRequestContentType(h *fasthttp.RequestHeader) []byte
Source: internal/mediatype/mediatype.go:21
NormalizeRequestContentType lowercases the case-insensitive parts of a request's Content-Type in place. The fold must land on the request's own bytes: fasthttp locates the boundary and the urlencoded body case-sensitively.
func Params(ct []byte) iter.Seq2[[]byte, []byte]
Source: internal/mediatype/mediatype.go:172
Params yields the trimmed name and value of each parameter in ct that has an "=".
func ParsesPostArgs(ct []byte) bool
Source: internal/mediatype/mediatype.go:102
ParsesPostArgs reports whether fasthttp's PostArgs reads the body under ct: it matches the urlencoded type as a case-insensitive prefix.
func StripParams(ct []byte) []byte
Source: internal/mediatype/mediatype.go:151
StripParams returns ct without its parameters and surrounding whitespace.
func Unescape(v []byte) ([]byte, bool)
Source: internal/mediatype/mediatype.go:258
Unescape resolves the quoted-pairs in v; ok is false if v ends in a lone backslash, which is kept.