Skip to main content

Module content_type

Module content_type 

Available on crate features http and std only.
Expand description

The Content-Type a recipient acts on, read as browsers do, so a proxy or server agrees with them:

  • extract_mime_type and extract_essence read a response as browsers do: WHATWG Fetch’s lenient “extract a MIME type” (§3.5) over every field line.
  • parse_essence and parse_mime_type judge a request as the CORS safelist does: MIME Sniffing’s “parse a MIME type” (§4.4) over the whole value. A decision that gates a request uses it, as the lenient reading finds application/json in a text/plain;,application/json sent without preflight.

Functions§

extract_essence
The type/subtype of the extracted type, as sent: all a decision on the media type needs.
extract_mime_type
The extracted type with its parameters, None when no line holds a valid one.
parse_essence
The type/subtype of the whole value as one media type, as sent: what the CORS safelist judges, so a request is gated on the type its sender was allowed to send.
parse_mime_type
The whole value as one media type with the parameters the mime crate can hold, see parse_essence.