HTTP Content-Type Parser
Parse an HTTP media type and its parameters, preserving parameter values and rejecting duplicate names.
Description
A Content-Type field identifies a media type plus optional parameters such as charset or boundary.
A Content-Type field identifies a media type plus optional parameters such as charset or boundary. Parameter name normalization must not alter parameter values.1
The returned values include Lowercase media type, Parameters in source order with unquoted values. The How section below explains the calculation, input rules and interpretation.
When to use HTTP Content-Type Parser
Use HTTP Content-Type Parser when you need to evaluate the supplied records under the calculation and evidence rules below. No body decoding, charset support, multipart integrity or media-type registration is verified. A trailing semicolon is malformed.
Paste the requested HTTP header field value. Use the field table to distinguish request cookies, media types and authorization credentials.
How to use HTTP Content-Type Parser and understand its results
- Paste the requested HTTP header field value. Use the field table to distinguish request cookies, media types and authorization credentials.
- Enter header using the field table and calculation rules, then run the tool.
- Read mediaType, parameters. The explanation below defines the units, signs, ordering and any flags or placeholder values.
- If the tool reports an input issue, correct the values and run it again. Apply the stated assumptions when interpreting a successfully returned result.
| Input field | Meaning | Value type; see rules below | Requirement |
|---|---|---|---|
| header | Content-Type field value. | string; maximum length: 1000000 | Required |
Paste the field value. Split semicolons outside quotes with shared escape-aware parsing. Require token/token media type; lowercase it. Require name=value parameters, lowercase names, accept token or quoted-string values, remove quotes/unescape quoted pairs and reject duplicate names ignoring case. Return ordered values preserving case.
mediaType=lowercase type/subtype; parameters=ordered unique names Units, indexing, boundary conditions and exceptional cases are defined in the calculation rules above.
| Output field | Meaning | Value type |
|---|---|---|
| mediaType | Lowercase media type. | string; maximum length: 1000000 |
| parameters | Parameters in source order with unquoted values. | list of object; minimum entries: 0; maximum entries: 100000 |
| parameters[].name | Field in parameters record | string; maximum length: 1000000 |
| parameters[].value | Field in parameters record | string; maximum length: 1000000 |
{
"input": {
"header": "Text/HTML; charset=\"UTF-8\"; boundary=\"a;b\""
},
"output": {
"mediaType": "text/html",
"parameters": [
{
"name": "charset",
"value": "UTF-8"
},
{
"name": "boundary",
"value": "a;b"
}
]
}
} Limitations and assumptions
No body decoding, charset support, multipart integrity or media-type registration is verified. A trailing semicolon is malformed.
Numeric inputs, where present, must be finite. Follow the calculation-specific rules for overflow, underflow and exceptional cases. Extremely large text inputs are rejected. Missing fields without a declared default, extra fields, wrong value types and violations of the calculation rules are input errors.
Alternative or Complementary methods
Use HTTP Cookie Parser: A request Cookie header contains ordered name/value pairs. Repeated names can arise, so collapsing them to an object can lose information. For a complementary task, use HTTP Basic Authentication Parser: HTTP Basic credentials encode username and password bytes as Base64. Base64 is reversible encoding, and choosing a text character set is a separate step.
References
-
HTTP Content-Type Parser — tool.io
Similar or alternative tools
- HTTP Cookie Parser
A request Cookie header contains ordered name/value pairs. Repeated names can arise, so collapsing them to an object can lose information.
- HTTP Basic Authentication Parser
HTTP Basic credentials encode username and password bytes as Base64. Base64 is reversible encoding, and choosing a text character set is a separate step.