| 1 |
<pre>Internet Engineering Task Force (IETF) J. Reschke |
| 2 |
Request for Comments: 6266 greenbytes |
| 3 |
Updates: <a href="./rfc2616">2616</a> June 2011 |
| 4 |
Category: Standards Track |
| 5 |
ISSN: 2070-1721 |
| 6 |
|
| 7 |
|
| 8 |
<span class="h1">Use of the Content-Disposition Header Field in the</span> |
| 9 |
<span class="h1">Hypertext Transfer Protocol (HTTP)</span> |
| 10 |
|
| 11 |
Abstract |
| 12 |
|
| 13 |
<a href="./rfc2616">RFC 2616</a> defines the Content-Disposition response header field, but |
| 14 |
points out that it is not part of the HTTP/1.1 Standard. This |
| 15 |
specification takes over the definition and registration of Content- |
| 16 |
Disposition, as used in HTTP, and clarifies internationalization |
| 17 |
aspects. |
| 18 |
|
| 19 |
Status of This Memo |
| 20 |
|
| 21 |
This is an Internet Standards Track document. |
| 22 |
|
| 23 |
This document is a product of the Internet Engineering Task Force |
| 24 |
(IETF). It represents the consensus of the IETF community. It has |
| 25 |
received public review and has been approved for publication by the |
| 26 |
Internet Engineering Steering Group (IESG). Further information on |
| 27 |
Internet Standards is available in <a href="./rfc5741#section-2">Section 2 of RFC 5741</a>. |
| 28 |
|
| 29 |
Information about the current status of this document, any errata, |
| 30 |
and how to provide feedback on it may be obtained at |
| 31 |
<a href="http://www.rfc-editor.org/info/rfc6266">http://www.rfc-editor.org/info/rfc6266</a>. |
| 32 |
|
| 33 |
Copyright Notice |
| 34 |
|
| 35 |
Copyright (c) 2011 IETF Trust and the persons identified as the |
| 36 |
document authors. All rights reserved. |
| 37 |
|
| 38 |
This document is subject to <a href="https://www.rfc-editor.org/bcp/bcp78">BCP 78</a> and the IETF Trust's Legal |
| 39 |
Provisions Relating to IETF Documents |
| 40 |
(<a href="http://trustee.ietf.org/license-info">http://trustee.ietf.org/license-info</a>) in effect on the date of |
| 41 |
publication of this document. Please review these documents |
| 42 |
carefully, as they describe your rights and restrictions with respect |
| 43 |
to this document. Code Components extracted from this document must |
| 44 |
include Simplified BSD License text as described in Section 4.e of |
| 45 |
the Trust Legal Provisions and are provided without warranty as |
| 46 |
described in the Simplified BSD License. |
| 47 |
|
| 48 |
|
| 49 |
|
| 50 |
|
| 51 |
|
| 52 |
<span class="grey">Reschke Standards Track [Page 1]</span></pre> |
| 53 |
<hr class='noprint'/><!--NewPage--><pre class='newpage'><span id="page-2" ></span> |
| 54 |
<span class="grey"><a href="./rfc6266">RFC 6266</a> Content-Disposition in HTTP June 2011</span> |
| 55 |
|
| 56 |
|
| 57 |
Table of Contents |
| 58 |
|
| 59 |
<a href="#section-1">1</a>. Introduction ....................................................<a href="#page-2">2</a> |
| 60 |
<a href="#section-2">2</a>. Notational Conventions ..........................................<a href="#page-3">3</a> |
| 61 |
<a href="#section-3">3</a>. Conformance and Error Handling ..................................<a href="#page-3">3</a> |
| 62 |
<a href="#section-4">4</a>. Header Field Definition .........................................<a href="#page-3">3</a> |
| 63 |
<a href="#section-4.1">4.1</a>. Grammar ....................................................<a href="#page-4">4</a> |
| 64 |
<a href="#section-4.2">4.2</a>. Disposition Type ...........................................<a href="#page-5">5</a> |
| 65 |
<a href="#section-4.3">4.3</a>. Disposition Parameter: 'Filename' ..........................<a href="#page-5">5</a> |
| 66 |
<a href="#section-4.4">4.4</a>. Disposition Parameter: Extensions ..........................<a href="#page-6">6</a> |
| 67 |
<a href="#section-4.5">4.5</a>. Extensibility ..............................................<a href="#page-7">7</a> |
| 68 |
<a href="#section-5">5</a>. Examples ........................................................<a href="#page-7">7</a> |
| 69 |
<a href="#section-6">6</a>. Internationalization Considerations .............................<a href="#page-8">8</a> |
| 70 |
<a href="#section-7">7</a>. Security Considerations .........................................<a href="#page-8">8</a> |
| 71 |
<a href="#section-8">8</a>. IANA Considerations .............................................<a href="#page-8">8</a> |
| 72 |
<a href="#section-8.1">8.1</a>. Registry for Disposition Values and Parameters .............<a href="#page-8">8</a> |
| 73 |
<a href="#section-8.2">8.2</a>. Header Field Registration ..................................<a href="#page-8">8</a> |
| 74 |
<a href="#section-9">9</a>. Acknowledgements ................................................<a href="#page-9">9</a> |
| 75 |
<a href="#section-10">10</a>. References .....................................................<a href="#page-9">9</a> |
| 76 |
<a href="#section-10.1">10.1</a>. Normative References ......................................<a href="#page-9">9</a> |
| 77 |
<a href="#section-10.2">10.2</a>. Informative References ....................................<a href="#page-9">9</a> |
| 78 |
<a href="#appendix-A">Appendix A</a>. Changes from the <a href="./rfc2616">RFC 2616</a> Definition ..................<a href="#page-11">11</a> |
| 79 |
<a href="#appendix-B">Appendix B</a>. Differences Compared to <a href="./rfc2183">RFC 2183</a> ......................<a href="#page-11">11</a> |
| 80 |
<a href="#appendix-C">Appendix C</a>. Alternative Approaches to Internationalization ........<a href="#page-11">11</a> |
| 81 |
<a href="#appendix-C.1">C.1</a>. <a href="./rfc2047">RFC 2047</a> Encoding ..........................................<a href="#page-12">12</a> |
| 82 |
<a href="#appendix-C.2">C.2</a>. Percent Encoding ...........................................<a href="#page-12">12</a> |
| 83 |
<a href="#appendix-C.3">C.3</a>. Encoding Sniffing ..........................................<a href="#page-12">12</a> |
| 84 |
<a href="#appendix-D">Appendix D</a>. Advice on Generating Content-Disposition Header |
| 85 |
Fields ................................................<a href="#page-13">13</a> |
| 86 |
|
| 87 |
<span class="h2"><a class="selflink" id="section-1" href="#section-1">1</a>. Introduction</span> |
| 88 |
|
| 89 |
<a href="./rfc2616">RFC 2616</a> defines the Content-Disposition response header field |
| 90 |
(<a href="./rfc2616#section-19.5.1">Section 19.5.1 of [RFC2616]</a>) but points out that it is not part of |
| 91 |
the HTTP/1.1 Standard (<a href="#section-15.5">Section 15.5</a>): |
| 92 |
|
| 93 |
Content-Disposition is not part of the HTTP standard, but since it |
| 94 |
is widely implemented, we are documenting its use and risks for |
| 95 |
implementers. |
| 96 |
|
| 97 |
This specification takes over the definition and registration of |
| 98 |
Content-Disposition, as used in HTTP. Based on interoperability |
| 99 |
testing with existing user agents (UAs), it fully defines a profile |
| 100 |
of the features defined in the Multipurpose Internet Mail Extensions |
| 101 |
(MIME) variant ([<a href="./rfc2183" title=""Communicating Presentation Information in Internet Messages: The Content-Disposition Header Field"">RFC2183</a>]) of the header field, and also clarifies |
| 102 |
internationalization aspects. |
| 103 |
|
| 104 |
|
| 105 |
|
| 106 |
|
| 107 |
|
| 108 |
<span class="grey">Reschke Standards Track [Page 2]</span></pre> |
| 109 |
<hr class='noprint'/><!--NewPage--><pre class='newpage'><span id="page-3" ></span> |
| 110 |
<span class="grey"><a href="./rfc6266">RFC 6266</a> Content-Disposition in HTTP June 2011</span> |
| 111 |
|
| 112 |
|
| 113 |
Note: This document does not apply to Content-Disposition header |
| 114 |
fields appearing in payload bodies transmitted over HTTP, such as |
| 115 |
when using the media type "multipart/form-data" ([<a href="./rfc2388" title=""Returning Values from Forms: multipart/ form-data"">RFC2388</a>]). |
| 116 |
|
| 117 |
<span class="h2"><a class="selflink" id="section-2" href="#section-2">2</a>. Notational Conventions</span> |
| 118 |
|
| 119 |
The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", |
| 120 |
"SHOULD", "SHOULD NOT", "RECOMMENDED", "MAY", and "OPTIONAL" in this |
| 121 |
document are to be interpreted as described in [<a href="./rfc2119" title=""Key words for use in RFCs to Indicate Requirement Levels"">RFC2119</a>]. |
| 122 |
|
| 123 |
This specification uses the augmented BNF (ABNF) notation defined in |
| 124 |
<a href="./rfc2616#section-2.1">Section 2.1 of [RFC2616]</a>, including its rules for implied linear |
| 125 |
whitespace (LWS). |
| 126 |
|
| 127 |
<span class="h2"><a class="selflink" id="section-3" href="#section-3">3</a>. Conformance and Error Handling</span> |
| 128 |
|
| 129 |
This specification defines conformance criteria for both senders |
| 130 |
(usually, HTTP origin servers) and recipients (usually, HTTP user |
| 131 |
agents) of the Content-Disposition header field. An implementation |
| 132 |
is considered conformant if it complies with all of the requirements |
| 133 |
associated with its role. |
| 134 |
|
| 135 |
This specification also defines certain forms of the header field |
| 136 |
value to be invalid, using both ABNF and prose requirements |
| 137 |
(<a href="#section-4">Section 4</a>), but it does not define special handling of these invalid |
| 138 |
field values. |
| 139 |
|
| 140 |
Senders MUST NOT generate Content-Disposition header fields that are |
| 141 |
invalid. |
| 142 |
|
| 143 |
Recipients MAY take steps to recover a usable field value from an |
| 144 |
invalid header field, but SHOULD NOT reject the message outright, |
| 145 |
unless this is explicitly desirable behavior (e.g., the |
| 146 |
implementation is a validator). As such, the default handling of |
| 147 |
invalid fields is to ignore them. |
| 148 |
|
| 149 |
<span class="h2"><a class="selflink" id="section-4" href="#section-4">4</a>. Header Field Definition</span> |
| 150 |
|
| 151 |
The Content-Disposition response header field is used to convey |
| 152 |
additional information about how to process the response payload, and |
| 153 |
also can be used to attach additional metadata, such as the filename |
| 154 |
to use when saving the response payload locally. |
| 155 |
|
| 156 |
|
| 157 |
|
| 158 |
|
| 159 |
|
| 160 |
|
| 161 |
|
| 162 |
|
| 163 |
|
| 164 |
<span class="grey">Reschke Standards Track [Page 3]</span></pre> |
| 165 |
<hr class='noprint'/><!--NewPage--><pre class='newpage'><span id="page-4" ></span> |
| 166 |
<span class="grey"><a href="./rfc6266">RFC 6266</a> Content-Disposition in HTTP June 2011</span> |
| 167 |
|
| 168 |
|
| 169 |
<span class="h3"><a class="selflink" id="section-4.1" href="#section-4.1">4.1</a>. Grammar</span> |
| 170 |
|
| 171 |
content-disposition = "Content-Disposition" ":" |
| 172 |
disposition-type *( ";" disposition-parm ) |
| 173 |
|
| 174 |
disposition-type = "inline" | "attachment" | disp-ext-type |
| 175 |
; case-insensitive |
| 176 |
disp-ext-type = token |
| 177 |
|
| 178 |
disposition-parm = filename-parm | disp-ext-parm |
| 179 |
|
| 180 |
filename-parm = "filename" "=" value |
| 181 |
| "filename*" "=" ext-value |
| 182 |
|
| 183 |
disp-ext-parm = token "=" value |
| 184 |
| ext-token "=" ext-value |
| 185 |
ext-token = <the characters in token, followed by "*"> |
| 186 |
|
| 187 |
Defined in [<a href="./rfc2616" title=""Hypertext Transfer Protocol -- HTTP/1.1"">RFC2616</a>]: |
| 188 |
|
| 189 |
token = <token, defined in <a href="./rfc2616#section-2.2">[RFC2616], Section 2.2</a>> |
| 190 |
quoted-string = <quoted-string, defined in <a href="./rfc2616#section-2.2">[RFC2616], Section 2.2</a>> |
| 191 |
value = <value, defined in <a href="./rfc2616#section-3.6">[RFC2616], Section 3.6</a>> |
| 192 |
; token | quoted-string |
| 193 |
|
| 194 |
Defined in [<a href="./rfc5987" title=""Character Set and Language Encoding for Hypertext Transfer Protocol (HTTP) Header Field Parameters"">RFC5987</a>]: |
| 195 |
|
| 196 |
ext-value = <ext-value, defined in <a href="./rfc5987#section-3.2">[RFC5987], Section 3.2</a>> |
| 197 |
|
| 198 |
Content-Disposition header field values with multiple instances of |
| 199 |
the same parameter name are invalid. |
| 200 |
|
| 201 |
Note that due to the rules for implied linear whitespace (<a href="./rfc2616#section-2.1">Section 2.1 |
| 202 |
of [RFC2616]</a>), OPTIONAL whitespace can appear between words (token or |
| 203 |
quoted-string) and separator characters. |
| 204 |
|
| 205 |
Furthermore, note that the format used for ext-value allows |
| 206 |
specifying a natural language (e.g., "en"); this is of limited use |
| 207 |
for filenames and is likely to be ignored by recipients. |
| 208 |
|
| 209 |
|
| 210 |
|
| 211 |
|
| 212 |
|
| 213 |
|
| 214 |
|
| 215 |
|
| 216 |
|
| 217 |
|
| 218 |
|
| 219 |
|
| 220 |
<span class="grey">Reschke Standards Track [Page 4]</span></pre> |
| 221 |
<hr class='noprint'/><!--NewPage--><pre class='newpage'><span id="page-5" ></span> |
| 222 |
<span class="grey"><a href="./rfc6266">RFC 6266</a> Content-Disposition in HTTP June 2011</span> |
| 223 |
|
| 224 |
|
| 225 |
<span class="h3"><a class="selflink" id="section-4.2" href="#section-4.2">4.2</a>. Disposition Type</span> |
| 226 |
|
| 227 |
If the disposition type matches "attachment" (case-insensitively), |
| 228 |
this indicates that the recipient should prompt the user to save the |
| 229 |
response locally, rather than process it normally (as per its media |
| 230 |
type). |
| 231 |
|
| 232 |
On the other hand, if it matches "inline" (case-insensitively), this |
| 233 |
implies default processing. Therefore, the disposition type "inline" |
| 234 |
is only useful when it is augmented with additional parameters, such |
| 235 |
as the filename (see below). |
| 236 |
|
| 237 |
Unknown or unhandled disposition types SHOULD be handled by |
| 238 |
recipients the same way as "attachment" (see also <a href="./rfc2183#section-2.8">[RFC2183], |
| 239 |
Section 2.8</a>). |
| 240 |
|
| 241 |
<span class="h3"><a class="selflink" id="section-4.3" href="#section-4.3">4.3</a>. Disposition Parameter: 'Filename'</span> |
| 242 |
|
| 243 |
The parameters "filename" and "filename*", to be matched case- |
| 244 |
insensitively, provide information on how to construct a filename for |
| 245 |
storing the message payload. |
| 246 |
|
| 247 |
Depending on the disposition type, this information might be used |
| 248 |
right away (in the "save as..." interaction caused for the |
| 249 |
"attachment" disposition type), or later on (for instance, when the |
| 250 |
user decides to save the contents of the current page being |
| 251 |
displayed). |
| 252 |
|
| 253 |
The parameters "filename" and "filename*" differ only in that |
| 254 |
"filename*" uses the encoding defined in [<a href="./rfc5987" title=""Character Set and Language Encoding for Hypertext Transfer Protocol (HTTP) Header Field Parameters"">RFC5987</a>], allowing the use |
| 255 |
of characters not present in the ISO-8859-1 character set |
| 256 |
([<a href="#ref-ISO-8859-1" title=""Information technology -- 8-bit single-byte coded graphic character sets -- Part 1: Latin alphabet No. 1"">ISO-8859-1</a>]). |
| 257 |
|
| 258 |
Many user agent implementations predating this specification do not |
| 259 |
understand the "filename*" parameter. Therefore, when both |
| 260 |
"filename" and "filename*" are present in a single header field |
| 261 |
value, recipients SHOULD pick "filename*" and ignore "filename". |
| 262 |
This way, senders can avoid special-casing specific user agents by |
| 263 |
sending both the more expressive "filename*" parameter, and the |
| 264 |
"filename" parameter as fallback for legacy recipients (see <a href="#section-5">Section 5</a> |
| 265 |
for an example). |
| 266 |
|
| 267 |
|
| 268 |
|
| 269 |
|
| 270 |
|
| 271 |
|
| 272 |
|
| 273 |
|
| 274 |
|
| 275 |
|
| 276 |
<span class="grey">Reschke Standards Track [Page 5]</span></pre> |
| 277 |
<hr class='noprint'/><!--NewPage--><pre class='newpage'><span id="page-6" ></span> |
| 278 |
<span class="grey"><a href="./rfc6266">RFC 6266</a> Content-Disposition in HTTP June 2011</span> |
| 279 |
|
| 280 |
|
| 281 |
It is essential that recipients treat the specified filename as |
| 282 |
advisory only, and thus be very careful in extracting the desired |
| 283 |
information. In particular: |
| 284 |
|
| 285 |
o Recipients MUST NOT be able to write into any location other than |
| 286 |
one to which they are specifically entitled. To illustrate the |
| 287 |
problem, consider the consequences of being able to overwrite |
| 288 |
well-known system locations (such as "/etc/passwd"). One strategy |
| 289 |
to achieve this is to never trust folder name information in the |
| 290 |
filename parameter, for instance by stripping all but the last |
| 291 |
path segment and only considering the actual filename (where 'path |
| 292 |
segments' are the components of the field value delimited by the |
| 293 |
path separator characters "\" and "/"). |
| 294 |
|
| 295 |
o Many platforms do not use Internet Media Types ([<a href="./rfc2046" title=""Multipurpose Internet Mail Extensions (MIME) Part Two: Media Types"">RFC2046</a>]) to hold |
| 296 |
type information in the file system, but rely on filename |
| 297 |
extensions instead. Trusting the server-provided file extension |
| 298 |
could introduce a privilege escalation when the saved file is |
| 299 |
later opened (consider ".exe"). Thus, recipients that make use of |
| 300 |
file extensions to determine the media type MUST ensure that a |
| 301 |
file extension is used that is safe, optimally matching the media |
| 302 |
type of the received payload. |
| 303 |
|
| 304 |
o Recipients SHOULD strip or replace character sequences that are |
| 305 |
known to cause confusion both in user interfaces and in filenames, |
| 306 |
such as control characters and leading and trailing whitespace. |
| 307 |
|
| 308 |
o Other aspects recipients need to be aware of are names that have a |
| 309 |
special meaning in the file system or in shell commands, such as |
| 310 |
"." and "..", "~", "|", and also device names. Recipients SHOULD |
| 311 |
ignore or substitute names like these. |
| 312 |
|
| 313 |
Note: Many user agents do not properly handle the escape character |
| 314 |
"\" when using the quoted-string form. Furthermore, some user |
| 315 |
agents erroneously try to perform unescaping of "percent" escapes |
| 316 |
(see <a href="#appendix-C.2">Appendix C.2</a>), and thus might misinterpret filenames |
| 317 |
containing the percent character followed by two hex digits. |
| 318 |
|
| 319 |
<span class="h3"><a class="selflink" id="section-4.4" href="#section-4.4">4.4</a>. Disposition Parameter: Extensions</span> |
| 320 |
|
| 321 |
To enable future extensions, recipients SHOULD ignore unrecognized |
| 322 |
parameters (see also <a href="./rfc2183#section-2.8">[RFC2183], Section 2.8</a>). |
| 323 |
|
| 324 |
|
| 325 |
|
| 326 |
|
| 327 |
|
| 328 |
|
| 329 |
|
| 330 |
|
| 331 |
|
| 332 |
<span class="grey">Reschke Standards Track [Page 6]</span></pre> |
| 333 |
<hr class='noprint'/><!--NewPage--><pre class='newpage'><span id="page-7" ></span> |
| 334 |
<span class="grey"><a href="./rfc6266">RFC 6266</a> Content-Disposition in HTTP June 2011</span> |
| 335 |
|
| 336 |
|
| 337 |
<span class="h3"><a class="selflink" id="section-4.5" href="#section-4.5">4.5</a>. Extensibility</span> |
| 338 |
|
| 339 |
Note that <a href="./rfc2183#section-9">Section 9 of [RFC2183]</a> defines IANA registries both for |
| 340 |
disposition types and disposition parameters. This registry is |
| 341 |
shared by different protocols using Content-Disposition, such as MIME |
| 342 |
and HTTP. Therefore, not all registered values may make sense in the |
| 343 |
context of HTTP. |
| 344 |
|
| 345 |
<span class="h2"><a class="selflink" id="section-5" href="#section-5">5</a>. Examples</span> |
| 346 |
|
| 347 |
Direct the UA to show "save as" dialog, with a filename of |
| 348 |
"example.html": |
| 349 |
|
| 350 |
Content-Disposition: Attachment; filename=example.html |
| 351 |
|
| 352 |
Direct the UA to behave as if the Content-Disposition header field |
| 353 |
wasn't present, but to remember the filename "an example.html" for a |
| 354 |
subsequent save operation: |
| 355 |
|
| 356 |
Content-Disposition: INLINE; FILENAME= "an example.html" |
| 357 |
|
| 358 |
Note: This uses the quoted-string form so that the space character |
| 359 |
can be included. |
| 360 |
|
| 361 |
Direct the UA to show "save as" dialog, with a filename containing |
| 362 |
the Unicode character U+20AC (EURO SIGN): |
| 363 |
|
| 364 |
Content-Disposition: attachment; |
| 365 |
filename*= UTF-8''%e2%82%ac%20rates |
| 366 |
|
| 367 |
Here, the encoding defined in [<a href="./rfc5987" title=""Character Set and Language Encoding for Hypertext Transfer Protocol (HTTP) Header Field Parameters"">RFC5987</a>] is also used to encode the |
| 368 |
non-ISO-8859-1 character. |
| 369 |
|
| 370 |
This example is the same as the one above, but adding the "filename" |
| 371 |
parameter for compatibility with user agents not implementing |
| 372 |
<a href="./rfc5987">RFC 5987</a>: |
| 373 |
|
| 374 |
Content-Disposition: attachment; |
| 375 |
filename="EURO rates"; |
| 376 |
filename*=utf-8''%e2%82%ac%20rates |
| 377 |
|
| 378 |
Note: Those user agents that do not support the <a href="./rfc5987">RFC 5987</a> encoding |
| 379 |
ignore "filename*" when it occurs after "filename". |
| 380 |
|
| 381 |
|
| 382 |
|
| 383 |
|
| 384 |
|
| 385 |
|
| 386 |
|
| 387 |
|
| 388 |
<span class="grey">Reschke Standards Track [Page 7]</span></pre> |
| 389 |
<hr class='noprint'/><!--NewPage--><pre class='newpage'><span id="page-8" ></span> |
| 390 |
<span class="grey"><a href="./rfc6266">RFC 6266</a> Content-Disposition in HTTP June 2011</span> |
| 391 |
|
| 392 |
|
| 393 |
<span class="h2"><a class="selflink" id="section-6" href="#section-6">6</a>. Internationalization Considerations</span> |
| 394 |
|
| 395 |
The "filename*" parameter (<a href="#section-4.3">Section 4.3</a>), using the encoding defined |
| 396 |
in [<a href="./rfc5987" title=""Character Set and Language Encoding for Hypertext Transfer Protocol (HTTP) Header Field Parameters"">RFC5987</a>], allows the server to transmit characters outside the |
| 397 |
ISO-8859-1 character set, and also to optionally specify the language |
| 398 |
in use. |
| 399 |
|
| 400 |
Future parameters might also require internationalization, in which |
| 401 |
case the same encoding can be used. |
| 402 |
|
| 403 |
<span class="h2"><a class="selflink" id="section-7" href="#section-7">7</a>. Security Considerations</span> |
| 404 |
|
| 405 |
Using server-supplied information for constructing local filenames |
| 406 |
introduces many risks. These are summarized in <a href="#section-4.3">Section 4.3</a>. |
| 407 |
|
| 408 |
Furthermore, implementers ought to be aware of the security |
| 409 |
considerations applying to HTTP (see <a href="./rfc2616#section-15">Section 15 of [RFC2616]</a>), and |
| 410 |
also the parameter encoding defined in [<a href="./rfc5987" title=""Character Set and Language Encoding for Hypertext Transfer Protocol (HTTP) Header Field Parameters"">RFC5987</a>] (see <a href="#section-5">Section 5</a>). |
| 411 |
|
| 412 |
<span class="h2"><a class="selflink" id="section-8" href="#section-8">8</a>. IANA Considerations</span> |
| 413 |
|
| 414 |
<span class="h3"><a class="selflink" id="section-8.1" href="#section-8.1">8.1</a>. Registry for Disposition Values and Parameters</span> |
| 415 |
|
| 416 |
This specification does not introduce any changes to the registration |
| 417 |
procedures for disposition values and parameters that are defined in |
| 418 |
<a href="./rfc2183#section-9">Section 9 of [RFC2183]</a>. |
| 419 |
|
| 420 |
<span class="h3"><a class="selflink" id="section-8.2" href="#section-8.2">8.2</a>. Header Field Registration</span> |
| 421 |
|
| 422 |
This document updates the definition of the Content-Disposition HTTP |
| 423 |
header field in the permanent HTTP header field registry (see |
| 424 |
[<a href="./rfc3864" title=""Registration Procedures for Message Header Fields"">RFC3864</a>]). |
| 425 |
|
| 426 |
Header field name: Content-Disposition |
| 427 |
|
| 428 |
Applicable protocol: http |
| 429 |
|
| 430 |
Status: standard |
| 431 |
|
| 432 |
Author/Change controller: IETF |
| 433 |
|
| 434 |
Specification document: this specification (<a href="#section-4">Section 4</a>) |
| 435 |
|
| 436 |
Related information: none |
| 437 |
|
| 438 |
|
| 439 |
|
| 440 |
|
| 441 |
|
| 442 |
|
| 443 |
|
| 444 |
<span class="grey">Reschke Standards Track [Page 8]</span></pre> |
| 445 |
<hr class='noprint'/><!--NewPage--><pre class='newpage'><span id="page-9" ></span> |
| 446 |
<span class="grey"><a href="./rfc6266">RFC 6266</a> Content-Disposition in HTTP June 2011</span> |
| 447 |
|
| 448 |
|
| 449 |
<span class="h2"><a class="selflink" id="section-9" href="#section-9">9</a>. Acknowledgements</span> |
| 450 |
|
| 451 |
Thanks to Adam Barth, Rolf Eike Beer, Stewart Bryant, Bjoern |
| 452 |
Hoehrmann, Alfred Hoenes, Roar Lauritzsen, Alexey Melnikov, Henrik |
| 453 |
Nordstrom, and Mark Nottingham for their valuable feedback. |
| 454 |
|
| 455 |
<span class="h2"><a class="selflink" id="section-10" href="#section-10">10</a>. References</span> |
| 456 |
|
| 457 |
<span class="h3"><a class="selflink" id="section-10.1" href="#section-10.1">10.1</a>. Normative References</span> |
| 458 |
|
| 459 |
[<a id="ref-ISO-8859-1">ISO-8859-1</a>] International Organization for Standardization, |
| 460 |
"Information technology -- 8-bit single-byte coded |
| 461 |
graphic character sets -- Part 1: Latin alphabet |
| 462 |
No. 1", ISO/IEC 8859-1:1998, 1998. |
| 463 |
|
| 464 |
[<a id="ref-RFC2119">RFC2119</a>] Bradner, S., "Key words for use in RFCs to Indicate |
| 465 |
Requirement Levels", <a href="https://www.rfc-editor.org/bcp/bcp14">BCP 14</a>, <a href="./rfc2119">RFC 2119</a>, March 1997. |
| 466 |
|
| 467 |
[<a id="ref-RFC2616">RFC2616</a>] Fielding, R., Gettys, J., Mogul, J., Frystyk, H., |
| 468 |
Masinter, L., Leach, P., and T. Berners-Lee, "Hypertext |
| 469 |
Transfer Protocol -- HTTP/1.1", <a href="./rfc2616">RFC 2616</a>, June 1999. |
| 470 |
|
| 471 |
[<a id="ref-RFC5987">RFC5987</a>] Reschke, J., "Character Set and Language Encoding for |
| 472 |
Hypertext Transfer Protocol (HTTP) Header Field |
| 473 |
Parameters", <a href="./rfc5987">RFC 5987</a>, August 2010. |
| 474 |
|
| 475 |
<span class="h3"><a class="selflink" id="section-10.2" href="#section-10.2">10.2</a>. Informative References</span> |
| 476 |
|
| 477 |
[<a id="ref-RFC2046">RFC2046</a>] Freed, N. and N. Borenstein, "Multipurpose Internet |
| 478 |
Mail Extensions (MIME) Part Two: Media Types", |
| 479 |
<a href="./rfc2046">RFC 2046</a>, November 1996. |
| 480 |
|
| 481 |
[<a id="ref-RFC2047">RFC2047</a>] Moore, K., "MIME (Multipurpose Internet Mail |
| 482 |
Extensions) Part Three: Message Header Extensions for |
| 483 |
Non-ASCII Text", <a href="./rfc2047">RFC 2047</a>, November 1996. |
| 484 |
|
| 485 |
[<a id="ref-RFC2183">RFC2183</a>] Troost, R., Dorner, S., and K. Moore, Ed., |
| 486 |
"Communicating Presentation Information in Internet |
| 487 |
Messages: The Content-Disposition Header Field", |
| 488 |
<a href="./rfc2183">RFC 2183</a>, August 1997. |
| 489 |
|
| 490 |
[<a id="ref-RFC2231">RFC2231</a>] Freed, N. and K. Moore, "MIME Parameter Value and |
| 491 |
Encoded Word Extensions: Character Sets, Languages, and |
| 492 |
Continuations", <a href="./rfc2231">RFC 2231</a>, November 1997. |
| 493 |
|
| 494 |
[<a id="ref-RFC2388">RFC2388</a>] Masinter, L., "Returning Values from Forms: multipart/ |
| 495 |
form-data", <a href="./rfc2388">RFC 2388</a>, August 1998. |
| 496 |
|
| 497 |
|
| 498 |
|
| 499 |
|
| 500 |
<span class="grey">Reschke Standards Track [Page 9]</span></pre> |
| 501 |
<hr class='noprint'/><!--NewPage--><pre class='newpage'><span id="page-10" ></span> |
| 502 |
<span class="grey"><a href="./rfc6266">RFC 6266</a> Content-Disposition in HTTP June 2011</span> |
| 503 |
|
| 504 |
|
| 505 |
[<a id="ref-RFC3864">RFC3864</a>] Klyne, G., Nottingham, M., and J. Mogul, "Registration |
| 506 |
Procedures for Message Header Fields", <a href="https://www.rfc-editor.org/bcp/bcp90">BCP 90</a>, |
| 507 |
<a href="./rfc3864">RFC 3864</a>, September 2004. |
| 508 |
|
| 509 |
[<a id="ref-RFC3986">RFC3986</a>] Berners-Lee, T., Fielding, R., and L. Masinter, |
| 510 |
"Uniform Resource Identifier (URI): Generic Syntax", |
| 511 |
STD 66, <a href="./rfc3986">RFC 3986</a>, January 2005. |
| 512 |
|
| 513 |
[<a id="ref-US-ASCII">US-ASCII</a>] American National Standards Institute, "Coded Character |
| 514 |
Set -- 7-bit American Standard Code for Information |
| 515 |
Interchange", ANSI X3.4, 1986. |
| 516 |
|
| 517 |
|
| 518 |
|
| 519 |
|
| 520 |
|
| 521 |
|
| 522 |
|
| 523 |
|
| 524 |
|
| 525 |
|
| 526 |
|
| 527 |
|
| 528 |
|
| 529 |
|
| 530 |
|
| 531 |
|
| 532 |
|
| 533 |
|
| 534 |
|
| 535 |
|
| 536 |
|
| 537 |
|
| 538 |
|
| 539 |
|
| 540 |
|
| 541 |
|
| 542 |
|
| 543 |
|
| 544 |
|
| 545 |
|
| 546 |
|
| 547 |
|
| 548 |
|
| 549 |
|
| 550 |
|
| 551 |
|
| 552 |
|
| 553 |
|
| 554 |
|
| 555 |
|
| 556 |
<span class="grey">Reschke Standards Track [Page 10]</span></pre> |
| 557 |
<hr class='noprint'/><!--NewPage--><pre class='newpage'><span id="page-11" ></span> |
| 558 |
<span class="grey"><a href="./rfc6266">RFC 6266</a> Content-Disposition in HTTP June 2011</span> |
| 559 |
|
| 560 |
|
| 561 |
<span class="h2"><a class="selflink" id="appendix-A" href="#appendix-A">Appendix A</a>. Changes from the <a href="./rfc2616">RFC 2616</a> Definition</span> |
| 562 |
|
| 563 |
Compared to <a href="./rfc2616#section-19.5.1">Section 19.5.1 of [RFC2616]</a>, the following normative |
| 564 |
changes reflecting actual implementations have been made: |
| 565 |
|
| 566 |
o According to <a href="./rfc2616">RFC 2616</a>, the disposition type "attachment" only |
| 567 |
applies to content of type "application/octet-stream". This |
| 568 |
restriction has been removed, because recipients in practice do |
| 569 |
not check the content type, and it also discourages properly |
| 570 |
declaring the media type. |
| 571 |
|
| 572 |
o <a href="./rfc2616">RFC 2616</a> only allows "quoted-string" for the filename parameter. |
| 573 |
This would be an exceptional parameter syntax, and also doesn't |
| 574 |
reflect actual use. |
| 575 |
|
| 576 |
o The definition for the disposition type "inline" (<a href="./rfc2183#section-2.1">[RFC2183], |
| 577 |
Section 2.1</a>) has been re-added with a suggestion for its |
| 578 |
processing. |
| 579 |
|
| 580 |
o This specification requires support for the extended parameter |
| 581 |
encoding defined in [<a href="./rfc5987" title=""Character Set and Language Encoding for Hypertext Transfer Protocol (HTTP) Header Field Parameters"">RFC5987</a>]. |
| 582 |
|
| 583 |
<span class="h2"><a class="selflink" id="appendix-B" href="#appendix-B">Appendix B</a>. Differences Compared to <a href="./rfc2183">RFC 2183</a></span> |
| 584 |
|
| 585 |
<a href="./rfc2183#section-2">Section 2 of [RFC2183]</a> defines several additional disposition |
| 586 |
parameters: "creation-date", "modification-date", "quoted-date-time", |
| 587 |
and "size". The majority of user agents do not implement these; |
| 588 |
thus, they have been omitted from this specification. |
| 589 |
|
| 590 |
<span class="h2"><a class="selflink" id="appendix-C" href="#appendix-C">Appendix C</a>. Alternative Approaches to Internationalization</span> |
| 591 |
|
| 592 |
By default, HTTP header field parameters cannot carry characters |
| 593 |
outside the ISO-8859-1 ([<a href="#ref-ISO-8859-1" title=""Information technology -- 8-bit single-byte coded graphic character sets -- Part 1: Latin alphabet No. 1"">ISO-8859-1</a>]) character encoding (see |
| 594 |
<a href="./rfc2616#section-2.2">[RFC2616], Section 2.2</a>). For the "filename" parameter, this of |
| 595 |
course is an unacceptable restriction. |
| 596 |
|
| 597 |
Unfortunately, user agent implementers have not managed to come up |
| 598 |
with an interoperable approach, although the IETF Standards Track |
| 599 |
specifies exactly one solution ([<a href="./rfc2231" title=""MIME Parameter Value and Encoded Word Extensions: Character Sets, Languages, and Continuations"">RFC2231</a>], clarified and profiled for |
| 600 |
HTTP in [<a href="./rfc5987" title=""Character Set and Language Encoding for Hypertext Transfer Protocol (HTTP) Header Field Parameters"">RFC5987</a>]). |
| 601 |
|
| 602 |
For completeness, the sections below describe the various approaches |
| 603 |
that have been tried, and explain how they are inferior to the |
| 604 |
<a href="./rfc5987">RFC 5987</a> encoding used in this specification. |
| 605 |
|
| 606 |
|
| 607 |
|
| 608 |
|
| 609 |
|
| 610 |
|
| 611 |
|
| 612 |
<span class="grey">Reschke Standards Track [Page 11]</span></pre> |
| 613 |
<hr class='noprint'/><!--NewPage--><pre class='newpage'><span id="page-12" ></span> |
| 614 |
<span class="grey"><a href="./rfc6266">RFC 6266</a> Content-Disposition in HTTP June 2011</span> |
| 615 |
|
| 616 |
|
| 617 |
<span class="h3"><a class="selflink" id="appendix-C.1" href="#appendix-C.1">C.1</a>. <a href="./rfc2047">RFC 2047</a> Encoding</span> |
| 618 |
|
| 619 |
<a href="./rfc2047">RFC 2047</a> defines an encoding mechanism for header fields, but this |
| 620 |
encoding is not supposed to be used for header field parameters -- |
| 621 |
see <a href="./rfc2047#section-5">Section 5 of [RFC2047]</a>: |
| 622 |
|
| 623 |
An 'encoded-word' MUST NOT appear within a 'quoted-string'. |
| 624 |
|
| 625 |
... |
| 626 |
|
| 627 |
An 'encoded-word' MUST NOT be used in parameter of a MIME Content- |
| 628 |
Type or Content-Disposition field, or in any structured field body |
| 629 |
except within a 'comment' or 'phrase'. |
| 630 |
|
| 631 |
In practice, some user agents implement the encoding, some do not |
| 632 |
(exposing the encoded string to the user), and some get confused by |
| 633 |
it. |
| 634 |
|
| 635 |
<span class="h3"><a class="selflink" id="appendix-C.2" href="#appendix-C.2">C.2</a>. Percent Encoding</span> |
| 636 |
|
| 637 |
Some user agents accept percent-encoded (<a href="./rfc3986#section-2.1">[RFC3986], Section 2.1</a>) |
| 638 |
sequences of characters. The character encoding being used for |
| 639 |
decoding depends on various factors, including the encoding of the |
| 640 |
referring page, the user agent's locale, its configuration, and also |
| 641 |
the actual value of the parameter. |
| 642 |
|
| 643 |
In practice, this is hard to use because those user agents that do |
| 644 |
not support it will display the escaped character sequence to the |
| 645 |
user. For those user agents that do implement this, it is difficult |
| 646 |
to predict what character encoding they actually expect. |
| 647 |
|
| 648 |
<span class="h3"><a class="selflink" id="appendix-C.3" href="#appendix-C.3">C.3</a>. Encoding Sniffing</span> |
| 649 |
|
| 650 |
Some user agents inspect the value (which defaults to ISO-8859-1 for |
| 651 |
the quoted-string form) and switch to UTF-8 when it seems to be more |
| 652 |
likely to be the correct interpretation. |
| 653 |
|
| 654 |
As with the approaches above, this is not interoperable and, |
| 655 |
furthermore, risks misinterpreting the actual value. |
| 656 |
|
| 657 |
|
| 658 |
|
| 659 |
|
| 660 |
|
| 661 |
|
| 662 |
|
| 663 |
|
| 664 |
|
| 665 |
|
| 666 |
|
| 667 |
|
| 668 |
<span class="grey">Reschke Standards Track [Page 12]</span></pre> |
| 669 |
<hr class='noprint'/><!--NewPage--><pre class='newpage'><span id="page-13" ></span> |
| 670 |
<span class="grey"><a href="./rfc6266">RFC 6266</a> Content-Disposition in HTTP June 2011</span> |
| 671 |
|
| 672 |
|
| 673 |
<span class="h2"><a class="selflink" id="appendix-D" href="#appendix-D">Appendix D</a>. Advice on Generating Content-Disposition Header Fields</span> |
| 674 |
|
| 675 |
To successfully interoperate with existing and future user agents, |
| 676 |
senders of the Content-Disposition header field are advised to: |
| 677 |
|
| 678 |
o Include a "filename" parameter when US-ASCII ([<a href="#ref-US-ASCII" title=""Coded Character Set -- 7-bit American Standard Code for Information Interchange"">US-ASCII</a>]) is |
| 679 |
sufficiently expressive. |
| 680 |
|
| 681 |
o Use the 'token' form of the filename parameter only when it does |
| 682 |
not contain disallowed characters (e.g., spaces); in such cases, |
| 683 |
the quoted-string form should be used. |
| 684 |
|
| 685 |
o Avoid including the percent character followed by two hexadecimal |
| 686 |
characters (e.g., %A9) in the filename parameter, since some |
| 687 |
existing implementations consider it to be an escape character, |
| 688 |
while others will pass it through unchanged. |
| 689 |
|
| 690 |
o Avoid including the "\" character in the quoted-string form of the |
| 691 |
filename parameter, as escaping is not implemented by some user |
| 692 |
agents, and "\" can be considered an illegal path character. |
| 693 |
|
| 694 |
o Avoid using non-ASCII characters in the filename parameter. |
| 695 |
Although most existing implementations will decode them as |
| 696 |
ISO-8859-1, some will apply heuristics to detect UTF-8, and thus |
| 697 |
might fail on certain names. |
| 698 |
|
| 699 |
o Include a "filename*" parameter where the desired filename cannot |
| 700 |
be expressed faithfully using the "filename" form. Note that |
| 701 |
legacy user agents will not process this, and will fall back to |
| 702 |
using the "filename" parameter's content. |
| 703 |
|
| 704 |
o When a "filename*" parameter is sent, to also generate a |
| 705 |
"filename" parameter as a fallback for user agents that do not |
| 706 |
support the "filename*" form, if possible. This can be done by |
| 707 |
substituting characters with US-ASCII sequences (e.g., Unicode |
| 708 |
character point U+00E4 (LATIN SMALL LETTER A WITH DIARESIS) by |
| 709 |
"ae"). Note that this may not be possible in some locales. |
| 710 |
|
| 711 |
o When a "filename" parameter is included as a fallback (as per |
| 712 |
above), "filename" should occur first, due to parsing problems in |
| 713 |
some existing implementations. |
| 714 |
|
| 715 |
o Use UTF-8 as the encoding of the "filename*" parameter, when |
| 716 |
present, because at least one existing implementation only |
| 717 |
implements that encoding. |
| 718 |
|
| 719 |
|
| 720 |
|
| 721 |
|
| 722 |
|
| 723 |
|
| 724 |
<span class="grey">Reschke Standards Track [Page 13]</span></pre> |
| 725 |
<hr class='noprint'/><!--NewPage--><pre class='newpage'><span id="page-14" ></span> |
| 726 |
<span class="grey"><a href="./rfc6266">RFC 6266</a> Content-Disposition in HTTP June 2011</span> |
| 727 |
|
| 728 |
|
| 729 |
Note that this advice is based upon UA behavior at the time of |
| 730 |
writing, and might be superseded. At the time of publication of this |
| 731 |
document, <<a href="http://purl.org/NET/http/content-disposition-tests">http://purl.org/NET/http/content-disposition-tests</a>> |
| 732 |
provides an overview of current levels of support in various |
| 733 |
implementations. |
| 734 |
|
| 735 |
Author's Address |
| 736 |
|
| 737 |
Julian F. Reschke |
| 738 |
greenbytes GmbH |
| 739 |
Hafenweg 16 |
| 740 |
Muenster, NW 48155 |
| 741 |
Germany |
| 742 |
|
| 743 |
EMail: [email protected] |
| 744 |
URI: <a href="http://greenbytes.de/tech/webdav/">http://greenbytes.de/tech/webdav/</a> |
| 745 |
|
| 746 |
|
| 747 |
|
| 748 |
|
| 749 |
|
| 750 |
|
| 751 |
|
| 752 |
|
| 753 |
|
| 754 |
|
| 755 |
|
| 756 |
|
| 757 |
|
| 758 |
|
| 759 |
|
| 760 |
|
| 761 |
|
| 762 |
|
| 763 |
|
| 764 |
|
| 765 |
|
| 766 |
|
| 767 |
|
| 768 |
|
| 769 |
|
| 770 |
|
| 771 |
|
| 772 |
|
| 773 |
|
| 774 |
|
| 775 |
|
| 776 |
|
| 777 |
|
| 778 |
|
| 779 |
|
| 780 |
Reschke Standards Track [Page 14] |
| 781 |
</pre> |