HTTP Content-Disposition Parser

Parse a disposition type and unquote its parameters, preserving RFC 5987 extended values for caller interpretation.

Description

Content-Disposition describes how content is presented and can carry filename parameters.

Content-Disposition describes how content is presented and can carry filename parameters. Extended parameter values need separate character-set interpretation.1, 2

Parse a disposition type and unquote its parameters, preserving RFC 5987 extended values for caller interpretation.

When to use HTTP Content-Disposition Parser

Use this tool to parse a disposition type and unquote its parameters, preserving RFC 5987 extended values for caller interpretation.

Prepare the header field value, cookie records or status code requested. Supply field values without a header-name prefix and preserve syntax for the parser to inspect.

How to use HTTP Content-Disposition Parser and understand its results

  1. Prepare the header field value, cookie records or status code requested. Supply field values without a header-name prefix and preserve syntax for the parser to inspect.
  2. Enter header using the field table and calculation rules, then run the tool.
  3. Read disposition, parameters. The explanation below defines the units, signs, ordering and any flags or placeholder values.
  4. 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 fieldMeaningValue type; see rules belowRequirement
headerContent-Disposition field value.string; maximum length: 1000000Required

Paste the field value. Split semicolons outside quoted strings/angle brackets, validate a token disposition, lowercase parameter names and unquote/unescape values. Reject repeated normalized parameter names; filename and filename* remain distinct. Preserve extended values such as UTF-8 percent-encoded text without decoding.3

disposition=lowercase token; parameters=ordered parsed name/value entries

Units, indexing, boundary conditions and exceptional cases are defined in the calculation rules above.

Output fieldMeaningValue type
dispositionLowercase disposition type.string; maximum length: 1000000
parametersParameters in source order with unquoted values.list of object; minimum entries: 0; maximum entries: 100000
json
{
  "input": {
    "header": "attachment; filename=\"report;final.csv\""
  },
  "output": {
    "disposition": "attachment",
    "parameters": [
      {
        "name": "filename",
        "value": "report;final.csv"
      }
    ]
  }
}

Limitations and assumptions

No filename sanitization, path safety, charset decoding or download action is supplied. This is a syntactic parser, not an exhaustive disposition-policy validator.

Numeric inputs must be finite. Follow the calculation-specific rules for overflow, underflow and exceptional cases. Extremely large text inputs are rejected. Missing required fields, extra fields, wrong value types and violations of the calculation rules are input errors.

Alternative or Complementary methods

Use HTTP Link Header Parser: Parse RFC 8288 link targets and parameters while retaining quoted delimiters and repeated relation parameters. For a complementary task, use HTTP Content-Type Parser: Parse an HTTP media type and its parameters, preserving parameter values and rejecting duplicate names.

Further background: RFC 6266: Content-Disposition in HTTP.

References

  1. HTTP Content-Disposition Parser — tool.io

  2. RFC 6266: Content-Disposition in HTTP — Internet Engineering Task Force

  3. HTTP Content-Type Parser — tool.io

Similar or alternative tools

  • HTTP Link Header Parser

    Parse RFC 8288 link targets and parameters while retaining quoted delimiters and repeated relation parameters.

  • HTTP Content-Type Parser

    Parse an HTTP media type and its parameters, preserving parameter values and rejecting duplicate names.

Don't forget to set a bookmark for tool.io!
Privacy | Imprint | Cookies