Web ArchitectureHTTP StandardAcronym: RFC 6266

What is Content-Disposition Header?

An HTTP response header that instructs web browsers whether to display content directly inline in the browser tab or save it locally as an attachment file with a specified filename.

Inline Display vs. File Attachment Directives

The Content-Disposition header dictates the user agent's presentation behavior. Setting `Content-Disposition: inline` instructs browsers to render the document or image inside the browser viewport if supported.

Setting `Content-Disposition: attachment; filename="invoice.pdf"` commands the browser to bypass rendering and trigger an operating system "Save As" file download dialog, pre-populating the specified filename.

RFC 5987 International Filename Encoding (filename*)

Legacy HTTP headers permitted only ASCII characters in filenames. RFC 6266 and RFC 5987 introduced extended parameters (`filename*=UTF-8''f%C3%BCr_kunde.pdf`) to support international characters and Unicode accents.

In client-side applications like DocSwift, programmatic file downloads are triggered locally using the HTML5 `<a download="filename.ext">` attribute and `URL.createObjectURL()`, achieving identical behavior without server response headers.

Key Advantages & Impact

  • Provides developers exact control over browser file download behaviors and default filenames
  • Protects users against cross-site script execution by forcing untrusted uploads to download as attachments
  • Supports full international character sets and localized filenames

Common Misconceptions vs Reality

❌ Myth:Content-Disposition specifies the file data format.
✓ Reality:Content-Disposition controls presentation/download behavior only. The MIME data format is specified exclusively by the Content-Type header.

Experience This Technology in DocSwift Tools

Frequently Asked Questions

How does DocSwift trigger file downloads without server headers?

DocSwift creates client-side Blob URLs (`blob:...`) and programmatically clicks temporary HTML5 `<a>` elements with the `download` attribute set.