<?xml version="1.0" encoding="utf-8"?>
<?xml-stylesheet type='text/xsl' href='rfc2629.xslt' ?>
<?rfc toc="yes"?>
<?rfc symrefs="yes"?>
<?rfc sortrefs="yes"?>
<?rfc compact="yes"?>
<?rfc comments="yes"?>
<?rfc inline="yes"?>
<?rfc subcompact="no"?>
<?rfc rfcedstyle="yes"?>
<?rfc-ext allow-markup-in-artwork="yes" ?>
<?rfc-ext include-references-in-index="yes" ?>

<!DOCTYPE rfc [
  <!ENTITY MAY "<bcp14 xmlns='http://purl.org/net/xml2rfc/ext'>MAY</bcp14>">
  <!ENTITY MUST "<bcp14 xmlns='http://purl.org/net/xml2rfc/ext'>MUST</bcp14>">
  <!ENTITY MUST-NOT "<bcp14 xmlns='http://purl.org/net/xml2rfc/ext'>MUST NOT</bcp14>">
  <!ENTITY OPTIONAL "<bcp14 xmlns='http://purl.org/net/xml2rfc/ext'>OPTIONAL</bcp14>">
  <!ENTITY RECOMMENDED "<bcp14 xmlns='http://purl.org/net/xml2rfc/ext'>RECOMMENDED</bcp14>">
  <!ENTITY REQUIRED "<bcp14 xmlns='http://purl.org/net/xml2rfc/ext'>REQUIRED</bcp14>">
  <!ENTITY SHALL "<bcp14 xmlns='http://purl.org/net/xml2rfc/ext'>SHALL</bcp14>">
  <!ENTITY SHALL-NOT "<bcp14 xmlns='http://purl.org/net/xml2rfc/ext'>SHALL NOT</bcp14>">
  <!ENTITY SHOULD "<bcp14 xmlns='http://purl.org/net/xml2rfc/ext'>SHOULD</bcp14>">
  <!ENTITY SHOULD-NOT "<bcp14 xmlns='http://purl.org/net/xml2rfc/ext'>SHOULD NOT</bcp14>">
]>

<rfc xmlns:x="http://purl.org/net/xml2rfc/ext" xmlns:ed="http://greenbytes.de/2002/rfcedit" ipr="trust200902" docName="draft-ietf-httpbis-content-disp-08" category="std" x:maturity-level="proposed" xml:lang="en" updates="2616">
	<front>
  <title abbrev="Content-Disposition in HTTP">Use of the Content-Disposition&#160;Header&#160;Field
  in the Hypertext&#160;Transfer&#160;Protocol&#160;(HTTP)</title>
  <author initials="J. F." surname="Reschke" fullname="Julian F. Reschke">
    <organization abbrev="greenbytes">greenbytes GmbH</organization>
    <address>
      <postal>
        <street>Hafenweg 16</street>
        <city>Muenster</city><region>NW</region><code>48155</code>
        <country>Germany</country>
      </postal>
      <email>julian.reschke@greenbytes.de</email>	
      <uri>http://greenbytes.de/tech/webdav/</uri>	
    </address>
  </author>

  <date month="March" year="2011" day="14"/>
  <workgroup>HTTPbis Working Group</workgroup>
  
  <abstract>
    <t>
      RFC 2616 defines the Content-Disposition response header field,
      but points out that it is not part of the HTTP/1.1 Standard. 
      This specification takes over the definition and registration of
      Content-Disposition, as used in HTTP, and clarifies internationalization
      aspects.
    </t>
  </abstract>
  
  <note title="Editorial Note (To be removed by RFC Editor before publication)">
    <t>
      This specification is expected to replace the definition of Content-Disposition
      in the HTTP/1.1 specification, as currently revised by the IETF HTTPbis
      working group. See also <eref target="http://trac.tools.ietf.org/wg/httpbis/trac/ticket/123"/>. 
    </t>
    <t>
      Discussion of this draft should take place on the HTTPBIS working group
      mailing list (ietf-http-wg@w3.org). The current issues list is
      at <eref target="http://trac.tools.ietf.org/wg/httpbis/trac/query?component=content-disp"/>
      and related documents (including fancy diffs) can be found at
      <eref target="http://tools.ietf.org/wg/httpbis/"/>.
    </t>
    <t>
      The changes in this draft are summarized in <xref target="changes.since.07"/>.
    </t>
  </note>
  </front>

  <middle>

<section title="Introduction" anchor="introduction">
<t>
  RFC 2616 defines the Content-Disposition response header field in <xref target="RFC2616" x:fmt="of" x:sec="19.5.1"/>,
  but points out that it is not part of the HTTP/1.1 Standard (<xref target="RFC2616" x:fmt="sec" x:sec="15.5"/>):
</t>
<x:blockquote cite="http://tools.ietf.org/html/rfc2616#section-15.5">
  <t>
    Content-Disposition is not part of the HTTP standard, but since it is
    widely implemented, we are documenting its use and risks for implementers.
  </t>
</x:blockquote>
<t>
  This specification takes over the definition and registration of
  Content-Disposition, as used in HTTP.
  Based on interoperability testing with existing User Agents, 
  it fully defines a profile of the
  features defined in the Multipurpose Internet Mail Extensions (MIME) variant (<xref target="RFC2183"/>) of the 
  header field, and also clarifies internationalization
  aspects.
</t>
<x:note>
  <t>
    <x:h>Note:</x:h> this document does not apply to Content-Disposition
    header fields appearing in payload bodies transmitted over HTTP, such as
    when using the media type "multipart/form-data" (<xref target="RFC2388"/>).
  </t>
</x:note>
</section>  

<section title="Notational Conventions" anchor="notational.conventions">
<t>
  The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT",
  "SHOULD", "SHOULD NOT", "RECOMMENDED", "MAY", and "OPTIONAL" in this document
  are to be interpreted as described in <xref target="RFC2119"/>.
</t>
<t>
  This specification uses the augmented BNF notation defined in
  <xref target="RFC2616" x:fmt="of" x:sec="2.1"/>, including its rules for
  implied linear whitespace (LWS).
</t>
</section>

<section title="Conformance and Error Handling" anchor="conformance.and.error.handling">
<t>
  This specification defines conformance criteria for both senders (usually,
  HTTP origin servers) and recipients (usually, HTTP user agents) of the
  Content-Disposition header field. An implementation is considered conformant if
  it complies with all of the requirements associated with its role.
</t>
<t>
  This specification also defines certain forms of the header field-value to be
  invalid, using both ABNF and prose requirements (<xref target="header.field.definition"/>),
  but it does not define special handling of these invalid field-values. 
</t>
<t>
  Senders &MUST-NOT; generate Content-Disposition header fields that are
  invalid.
</t>
<t>
  Recipients &MAY; take steps to recover a usable field-value
  from an invalid header field, but &SHOULD-NOT; reject the message outright,
  unless this is explicitly desirable behaviour (e.g., the implementation is a
  validator). As such, the default handling of invalid fields is to ignore them. 
</t>
</section>

<section title="Header Field Definition" anchor="header.field.definition">
  <iref item="Header Fields" subitem="Content-Disposition" primary="true" x:for-anchor=""/>
  <iref item="Content-Disposition header field" primary="true" x:for-anchor=""/>
<t>
  The Content-Disposition response header field is used to convey additional
  information about how to process the response payload, and also can be used
  to attach additional metadata, such as the filename to use when saving the
  response payload locally.
</t>

<section title="Grammar">
<figure><artwork type="abnf2616">
  content-disposition = "Content-Disposition" ":"
                         disposition-type *( ";" disposition-parm )

  disposition-type    = "inline" | "attachment" | disp-ext-type
                      ; case-insensitive
  disp-ext-type       = token

  disposition-parm    = filename-parm | disp-ext-parm

  filename-parm       = "filename" "=" value
                      | "filename*" "=" ext-value
  
  disp-ext-parm       = token "=" value
                      | ext-token "=" ext-value
  ext-token           = &lt;the characters in token, followed by "*"&gt;
</artwork></figure>

<figure>
<preamble>Defined in <xref target="RFC2616"/>:</preamble>
<artwork type="abnf2616">
  token         = &lt;token, defined in <xref target="RFC2616" x:fmt="," x:sec="2.2"/>&gt;
  quoted-string = &lt;quoted-string, defined in <xref target="RFC2616" x:fmt="," x:sec="2.2"/>&gt;
  value         = &lt;value, defined in <xref target="RFC2616" x:fmt="," x:sec="3.6"/>&gt;
                ; token | quoted-string
              
</artwork></figure>
<figure>
<preamble>Defined in <xref target="RFC5987"/>:</preamble>
<artwork type="abnf2616">
  ext-value   = &lt;ext-value, defined in <xref target="RFC5987" x:sec="3.2"/>&gt;
</artwork></figure>
<t>
  Header field values with multiple instances of the same parameter name are
  invalid.
</t>
<t>
  Note that due to the rules for implied linear whitespace
  (<xref target="RFC2616" x:fmt="of" x:sec="2.1"/>), &OPTIONAL; whitespace can
  appear between words (token or quoted-string) and separator characters.
</t>
<t>
  Furthermore note that the format used for ext-value allows specifying a
  natural language; this is of limited use for filenames and is likely to be
  ignored by recipients.
</t>
</section>

<section title="Disposition Type" anchor="disposition.type">
<t>
  If the disposition type matches "attachment" (case-insensitively), this
  indicates that the recipient should prompt the user to save the response
  locally, rather than process it normally (as per its media type).
</t>
<t>
  On the other hand, if it matches "inline" (case-insensitively), this implies
  default processing. Therefore, the disposition type "inline" is only useful
  when it is augmented with additional parameters, such as the filename (see
  below).
</t>
<t>
  Unknown or unhandled disposition types &SHOULD; be handled by recipients the
  same way as "attachment" (see also <xref target="RFC2183" x:fmt="," x:sec="2.8"/>).
</t>
</section>

<section title="Disposition Parameter: 'Filename'" anchor="disposition.parameter.filename">
<t>
  The parameters "filename" and "filename*", to be matched case-insensitively,
  provide information on how to construct a filename for storing the message
  payload.
</t>
<t>
  Depending on the disposition type, this information might be used right away
  (in the "save as..." interaction caused for the "attachment" disposition type),
  or later on (for instance, when the user decides to save the contents of the
  current page being displayed). 
</t>
<t>
  The parameters "filename" and "filename*" differ only in that "filename*" uses
  the encoding defined in <xref target="RFC5987"/>, allowing the use 
  of characters not present in the ISO-8859-1 character set (<xref target="ISO-8859-1"/>).
</t>
<t>
  Many user agent implementations predating this specification
  do not understand the "filename*" parameter. Therefore, when both "filename"
  and "filename*" are present in a single header field value, recipients
  &SHOULD; pick "filename*" and ignore "filename". This way, senders
  can avoid special-casing specific user agents by sending both the
  more expressive "filename*" parameter, and the "filename" parameter
  as fallback for legacy recipients (see <xref target="examples"/> for 
  an example).
</t>
<t>
  It is essential that recipients treat the specified filename as advisory
  only, thus be very careful in extracting the desired information.
  In particular:
  <list style="symbols">
    <x:lt><t>
      Recipients &MUST-NOT; be able to write into any location other than one
      to which they are specifically entitled. To illustrate the problem
      consider the consequences of being able to overwrite well-known system
      locations (such as "/etc/passwd"). One strategy to achieve this is to
      never trust folder name information in the filename parameter, for
      instance by stripping all but the last path segment and only consider the
      actual filename (where 'path segment' are the components of the field
      value delimited by the path separator characters "\" and "/").
    </t></x:lt>
    <x:lt><t>
      Many platforms do not use Internet Media Types (<xref target="RFC2046"/>)
      to hold type information in the file system, but rely on filename
      extensions instead. Trusting the server-provided file extension could
      introduce a privilege escalation when the saved file is later opened 
      (consider ".exe"). Thus, recipients &SHOULD; ensure that a file extension
      is used that is safe, optimally matching the media type of the received
      payload.
    </t></x:lt>
    <x:lt><t>
      Recipients &SHOULD; strip or replace character sequences that are
      known to cause confusion both in user interfaces and in filenames, such as
      control characters and leading and trailing whitespace.
    </t></x:lt>
    <x:lt><t>
      Other aspects recipients need to be aware of are names that have a 
      special meaning in the file system or in shell commands, such as "." and "..",
      "~", "|", and also device names. Recipients &SHOULD; ignore or substitute
      names like these.
    </t></x:lt>
  </list>
</t>
<x:note>
  <t>
    <x:h>Note:</x:h> Many user agents do not properly handle the escape
    character "\" when using the quoted-string form. Furthermore, some user agents
    erroneously try to perform unescaping of "percent" escapes (see
    <xref target="alternatives.percent"/>), and thus might misinterpret
    filenames containing the percent character followed by two hex digits.
  </t>
</x:note>
</section>

<section title="Disposition Parameter: Extensions" anchor="disposition.parameter.extensions">
<t>
  To enable future extensions, recipients &SHOULD; ignore unrecognized
  parameters (see also <xref target="RFC2183" x:fmt="," x:sec="2.8"/>).
</t>
</section>

<section title="Extensibility" anchor="extensibility">
<t>
  Note that <xref target="RFC2183" x:fmt="of" x:sec="9"/> defines IANA registries both
  for disposition types and disposition parameters. This registry is
  shared by different protocols using Content-Disposition, such as MIME and HTTP.
  Therefore, not all registered values may make sense in the context of HTTP.
</t>
</section>

</section>  

<section title="Examples" anchor="examples">

<figure>
<preamble>
Direct UA to show "save as" dialog, with a filename of "example.html":  
</preamble>
<artwork type="example">
Content-Disposition: Attachment; filename=example.html
</artwork></figure>
<figure>
<preamble>
Direct UA to behave as if the Content-Disposition header field wasn't present,
but to remember the filename "an example.html" for a subsequent save operation:
</preamble>
<artwork type="example" x:indent-with="  ">
Content-Disposition: INLINE; FILENAME= "an example.html"
</artwork>
<postamble>
  Note: this uses the quoted-string form so that the space character
  can be included.
</postamble>
</figure>
<figure>
<preamble>
Direct UA to show "save as" dialog, with a filename containing the Unicode character  U+20AC (EURO SIGN):
</preamble>
<artwork type="example" x:indent-with="  ">
Content-Disposition: attachment; 
                     filename*= UTF-8''<x:highlight>%e2%82%ac</x:highlight>%20rates
</artwork>
<postamble>
  Here, the encoding defined in <xref target="RFC5987"/> is also used to encode the 
  non-ISO-8859-1 character.
</postamble>
</figure>
<figure>
<preamble>
Same as above, but adding the "filename" parameter for compatibility with
user agents not implementing RFC 5987:
</preamble>
<artwork type="example" x:indent-with="  ">
Content-Disposition: attachment;
                     filename="EURO rates";
                     filename*=utf-8''<x:highlight>%e2%82%ac</x:highlight>%20rates
</artwork>
<postamble>
  Note: those user agents that do not support the RFC 5987 encoding ignore
  "filename*" when it occurs after "filename".
</postamble>
</figure>

</section>

<section title="Internationalization Considerations" anchor="i18n">
<t>
  The "filename*" parameter (<xref target="disposition.parameter.filename"/>),
  using the encoding defined in <xref target="RFC5987"/>, allows the 
  server to transmit characters outside the ISO-8859-1 character set,
  and also to optionally specify the language in use.
</t>
<t>
  Future parameters might also require internationalization, in which case
  the same encoding can be used.
</t>
</section>

<section title="Security Considerations" anchor="security.considerations">
<t>
  Using server-supplied information for constructing local filenames introduces
  many risks. These are summarized in <xref target="disposition.parameter.filename"/>.
</t>
<t>
  Furthermore, implementers also ought to be aware of the Security
  Considerations applying to HTTP (see <xref target="RFC2616" x:fmt="of" x:sec="15"/>), and also the parameter encoding defined in <xref target="RFC5987"/>
  (see <xref target="RFC5987" x:fmt="sec" x:sec="5"/>). 
</t>
</section>  

<section title="IANA Considerations" anchor="iana.considerations">

<section title="Registry for Disposition Values and Parameter" anchor="registry">
<t>
  This specification does not introduce any changes to the registration
  procedures for disposition values and parameters that are defined in 
  <xref target="RFC2183" x:fmt="of" x:sec="9"/>.
</t>
</section>

<section title="Header Field Registration" anchor="header.field.registration"> 
<t>
  This document updates the definition of the Content-Disposition HTTP header field
  in the permanent HTTP header field registry (see <xref target="RFC3864"/>).
</t>
<t>
<list style="hanging">
  <t hangText="Header field name:">Content-Disposition</t>
  <t hangText="Applicable protocol:">http</t>
  <t hangText="Status:">standard</t>
  <t hangText="Author/Change controller:">IETF</t>
  <t hangText="Specification document:">this specification (<xref target="header.field.definition"/>)</t>
</list>
</t>
</section>

</section>  

<section title="Acknowledgements">
<t>
  Thanks to
  Adam Barth,
  Rolf Eike Beer,
  Stewart Bryant,
  Bjoern Hoehrmann,
  Alfred Hoenes,
  Roar Lauritzsen,
  Alexey Melnikov,
  Henrik Nordstrom, and 
  Mark Nottingham for
  their valuable feedback.
</t>
</section>  

  </middle>
  <back>
  
<references title="Normative References">
  
  <reference anchor="RFC2119">
    <front>
      <title abbrev="RFC Key Words">Key words for use in RFCs to Indicate Requirement Levels</title>
      <author initials="S." surname="Bradner" fullname="Scott Bradner">
        <organization>Harvard University</organization>
        <address><email>sob@harvard.edu</email></address>
      </author>
      <date month="March" year="1997"/>
      <area>General</area>
      <keyword>keyword</keyword>
    </front>
    <seriesInfo name="BCP" value="14"/>
    <seriesInfo name="RFC" value="2119"/>
  </reference>

  <reference anchor="RFC2616">
    <front>
      <title>Hypertext Transfer Protocol -- HTTP/1.1</title>
      <author initials="R." surname="Fielding" fullname="R. Fielding">
        <organization>University of California, Irvine</organization>
        <address><email>fielding@ics.uci.edu</email></address>
      </author>
      <author initials="J." surname="Gettys" fullname="J. Gettys">
        <organization>W3C</organization>
        <address><email>jg@w3.org</email></address>
      </author>
      <author initials="J." surname="Mogul" fullname="J. Mogul">
        <organization>Compaq Computer Corporation</organization>
        <address><email>mogul@wrl.dec.com</email></address>
      </author>
      <author initials="H." surname="Frystyk" fullname="H. Frystyk">
        <organization>MIT Laboratory for Computer Science</organization>
        <address><email>frystyk@w3.org</email></address>
      </author>
      <author initials="L." surname="Masinter" fullname="L. Masinter">
        <organization>Xerox Corporation</organization>
        <address><email>masinter@parc.xerox.com</email></address>
      </author>
      <author initials="P." surname="Leach" fullname="P. Leach">
        <organization>Microsoft Corporation</organization>
        <address><email>paulle@microsoft.com</email></address>
      </author>
      <author initials="T." surname="Berners-Lee" fullname="T. Berners-Lee">
        <organization>W3C</organization>
        <address><email>timbl@w3.org</email></address>
      </author>
      <date month="June" year="1999"/>
    </front>
    <seriesInfo name="RFC" value="2616"/>
  </reference>

  <reference anchor="RFC5987">
  	<front>
      <title>Character Set and Language Encoding for Hypertext Transfer Protocol (HTTP) Header Field Parameters</title>
      <author initials="J. F." surname="Reschke" fullname="Julian F. Reschke">
        <organization abbrev="greenbytes">greenbytes GmbH</organization>
        <address>
          <postal>
            <street>Hafenweg 16</street>
            <city>Muenster</city><region>NW</region><code>48155</code>
            <country>Germany</country>
          </postal>
          <email>julian.reschke@greenbytes.de</email>	
          <uri>http://greenbytes.de/tech/webdav/</uri>	
        </address>
      </author>
      <date month="August" year="2010"/>
    </front>
    <seriesInfo name="RFC" value="5987"/>
  </reference>

  <reference anchor="ISO-8859-1">
    <front>
      <title>Information technology -- 8-bit single-byte coded graphic character sets -- Part 1: Latin alphabet No. 1</title>
      <author>
        <organization>International Organization for Standardization</organization>
      </author>
      <date year="1998"/>
    </front>
    <seriesInfo name="ISO/IEC" value="8859-1:1998"/>
  </reference>

</references>
  
<references title="Informative References">

  <reference anchor="RFC2046">
    <front>
      <title abbrev="Media Types">Multipurpose Internet Mail Extensions (MIME) Part Two: Media Types</title>
      <author initials="N." surname="Freed" fullname="Ned Freed">
        <organization>Innosoft International, Inc.</organization>
        <address><email>ned@innosoft.com</email></address>
      </author>
      <author initials="N." surname="Borenstein" fullname="Nathaniel S. Borenstein">
        <organization>First Virtual Holdings</organization>
        <address><email>nsb@nsb.fv.com</email></address>
      </author>
      <date month="November" year="1996"/>
    </front>
    <seriesInfo name="RFC" value="2046"/>
  </reference>

  <reference anchor="RFC2047">
    <front>
      <title abbrev="Message Header Extensions">MIME (Multipurpose Internet Mail Extensions) Part Three: Message Header Extensions for Non-ASCII Text</title>
      <author initials="K." surname="Moore" fullname="Keith Moore">
        <organization>University of Tennessee</organization>
        <address><email>moore@cs.utk.edu</email></address>
      </author>
      <date month="November" year="1996"/>
    </front>
    <seriesInfo name="RFC" value="2047"/>
  </reference>

  <reference anchor="RFC2183">
    <front>
      <title abbrev="Content-Disposition">Communicating Presentation Information in Internet Messages: The Content-Disposition Header Field</title>
      <author initials="R." surname="Troost" fullname="Rens Troost">
        <organization>New Century Systems</organization>
        <address><email>rens@century.com</email></address>
      </author>
      <author initials="S." surname="Dorner" fullname="Steve Dorner">
        <organization>QUALCOMM Incorporated</organization>
        <address><email>sdorner@qualcomm.com</email></address>
      </author>
      <author initials="K." surname="Moore" fullname="Keith Moore">
        <organization>Department of Computer Science</organization>
        <address><email>moore@cs.utk.edu</email></address>
      </author>
      <date year="1997" month="August"/>
    </front>
    <seriesInfo name="RFC" value="2183"/>
  </reference>

  <reference anchor="RFC2231">
    <front>
      <title abbrev="MIME Value and Encoded Word Extensions">MIME Parameter Value and Encoded Word Extensions: Character Sets, Languages, and Continuations</title>
      <author initials="N." surname="Freed" fullname="Ned Freed">
        <organization abbrev="Innosoft">Innosoft International, Inc.</organization>
        <address><email>ned.freed@innosoft.com</email></address>
      </author>
      <author initials="K." surname="Moore" fullname="Keith Moore">
        <organization>University of Tennessee</organization>
        <address><email>moore@cs.utk.edu</email></address>
      </author>
      <date year="1997" month="November"/>
    </front>
    <seriesInfo name="RFC" value="2231"/>
  </reference>

  <reference anchor="RFC2388">
    <front>
      <title abbrev="multipart/form-data">Returning Values from Forms: multipart/form-data</title>
      <author initials="L." surname="Masinter" fullname="Larry Masinter">
        <organization>Xerox Palo Alto Research Center</organization>
        <address>
          <email>masinter@parc.xerox.com</email>
        </address>
      </author>
      <date year="1998" month="August"/>
    </front>
    <seriesInfo name="RFC" value="2388"/>
  </reference>
<!--
  <reference anchor="RFC3629">
    <front>
      <title>UTF-8, a transformation format of ISO 10646</title>
      <author initials="F." surname="Yergeau" fullname="F. Yergeau">
        <organization>Alis Technologies</organization>
        <address><email>fyergeau@alis.com</email></address>
      </author>
      <date month="November" year="2003"/>
    </front>
    <seriesInfo name="STD" value="63"/>
    <seriesInfo name="RFC" value="3629"/>
  </reference>-->

  <reference anchor="RFC3864">
    <front>
      <title>Registration Procedures for Message Header Fields</title>
      <author initials="G." surname="Klyne" fullname="G. Klyne">
        <organization>Nine by Nine</organization>
        <address><email>GK-IETF@ninebynine.org</email></address>
      </author>
      <author initials="M." surname="Nottingham" fullname="M. Nottingham">
        <organization>BEA Systems</organization>
        <address><email>mnot@pobox.com</email></address>
      </author>
      <author initials="J." surname="Mogul" fullname="J. Mogul">
        <organization>HP Labs</organization>
        <address><email>JeffMogul@acm.org</email></address>
      </author>
      <date year="2004" month="September"/>
    </front>
    <seriesInfo name="BCP" value="90"/>
    <seriesInfo name="RFC" value="3864"/>
  </reference>

  <reference anchor="RFC3986">
   <front>
    <title abbrev="URI Generic Syntax">Uniform Resource Identifier (URI): Generic Syntax</title>
    <author initials="T." surname="Berners-Lee" fullname="Tim Berners-Lee">
      <organization abbrev="W3C/MIT">World Wide Web Consortium</organization>
      <address>
         <email>timbl@w3.org</email>
         <uri>http://www.w3.org/People/Berners-Lee/</uri>
      </address>
    </author>
    <author initials="R." surname="Fielding" fullname="Roy T. Fielding">
      <organization abbrev="Day Software">Day Software</organization>
      <address>
        <email>fielding@gbiv.com</email>
        <uri>http://roy.gbiv.com/</uri>
      </address>
    </author>
    <author initials="L." surname="Masinter" fullname="Larry Masinter">
      <organization abbrev="Adobe Systems">Adobe Systems Incorporated</organization>
      <address>
        <email>LMM@acm.org</email>
        <uri>http://larry.masinter.net/</uri>
      </address>
    </author>
    <date month="January" year="2005"/>
   </front>
   <seriesInfo name="STD" value="66"/>
   <seriesInfo name="RFC" value="3986"/>
  </reference>

</references>

<section title="Changes from the RFC 2616 Definition" anchor="changes.from.rfc2616">
<t>
  Compared to <xref target="RFC2616" x:fmt="of" x:sec="19.5.1"/>, the following
  normative changes reflecting actual implementations have been made:
<list style="symbols">
  <t>
    According to RFC 2616, the disposition type "attachment" only applies to
    content of type "application/octet-stream". This restriction has been 
    removed, because recipients in practice do not check the content type, and
    it also discourages properly declaring the media type.
  </t>
  <t>
    RFC 2616 only allows "quoted-string" for the filename parameter. This 
    would be an exceptional parameter syntax, and also doesn't reflect actual
    use.
  </t>
  <t>
    The definition for the disposition type "inline" (<xref target="RFC2183" x:fmt="," x:sec="2.1"/>)
    has been re-added with a suggestion for its processing.
  </t>
  <t>
    This specification requires support for the extended parameter encoding
    defined in <xref target="RFC5987"/>.
  </t>
</list>
</t>
</section>

<section title="Differences compared to RFC 2183" anchor="diffs.compared.to.rfc2183">
<t>
  <xref target="RFC2183" x:fmt="of" x:sec="2"/> defines several additional
  disposition parameters: "creation-date", "modification-date",
  "quoted-date-time", and "size". The majority of user agents does not implement
  these, thus they have been omitted from this specification.
</t>
</section>

<section title="Alternative Approaches to Internationalization" anchor="alternatives">
<t>
  By default, HTTP header field parameters cannot carry characters outside
  the ISO-8859-1 (<xref target="ISO-8859-1"/>) character encoding (see
  <xref target="RFC2616" x:fmt="," x:sec="2.2"/>). For the "filename"
  parameter, this of course is an unacceptable restriction.
</t>
<t>
  Unfortunately, user agent implementers have not managed to come up with
  an interoperable approach, although the IETF Standards Track specifies
  exactly one solution (<xref target="RFC2231"/>, clarified and profiled for
  HTTP in <xref target="RFC5987"/>).
</t>
<t>
  For completeness, the sections below describe the various approaches that
  have been tried, and explains how they are inferior to the RFC 5987
  encoding used in this specification.
</t>

<section title="RFC 2047 Encoding" anchor="alternatives.rfc2047">
<t>
  RFC 2047 defines an encoding mechanism for
  header fields, but this encoding is not supposed to be used for
  header field parameters - see <xref target="RFC2047" x:fmt="of" x:sec="5"/>:  
</t>
<x:blockquote cite="http://tools.ietf.org/html/rfc2047#section-5">
  <t>
    An 'encoded-word' MUST NOT appear within a 'quoted-string'.
  </t>
  <t>
    ...
  </t>
  <t>
    An 'encoded-word' MUST NOT be used in parameter of a MIME Content-Type or Content-Disposition field, or in any structured field body except within a 'comment' or 'phrase'.
  </t>
</x:blockquote>
<t>
  In practice, some user agents implement the encoding, some do not
  (exposing the encoded string to the user), and some get confused by it.
</t>
</section>

<section title="Percent Encoding" anchor="alternatives.percent">
<t>
  Some user agents accept percent encoded (<xref target="RFC3986" x:fmt="," x:sec="2.1"/>)
  sequences of characters. The character encoding being used for decoding
  depends on various factors, including the encoding of the referring page,
  the user agent's locale, its configuration, and also the actual value of
  the parameter.
</t>
<t>
  In practice, this is hard to use because those user agents that do not
  support it will display the escaped character sequence to the user. For those
  user agents that do implement this it is difficult to predict what character
  encoding they actually expect.
</t>
</section>

<section title="Encoding Sniffing" anchor="alternatives.sniff">
<t>
  Some user agents inspect the value (which defaults to ISO-8859-1 for the
  quoted-string form) and switch to UTF-8 when it seems to be more likely to be
  the correct interpretation.
</t>
<t>
  As with the approaches above, this is not interoperable and furthermore
  risks misinterpreting the actual value.
</t>
</section>

<section title="Implementations (to be removed by RFC Editor before publication)" anchor="alternatives.implementations">
<t>
  Unfortunately, as of March 2011, neither the encoding defined in RFCs 2231
  and 5987, nor any of the alternate approaches discussed above was
  implemented interoperably. Thus, this specification recommends the approach
  defined in RFC 5987, which at least has the advantage of actually being 
  specified properly.
</t>
<t>
  The table below shows the implementation support for the various approaches:
</t>
<texttable align="left">
  <ttcol>User Agent</ttcol>
  <ttcol>RFC 2231/5987</ttcol>
  <ttcol>RFC 2047</ttcol>
  <ttcol>Percent Encoding</ttcol>
  <ttcol>Encoding Sniffing</ttcol>
  
  <c>Chrome</c>
  <c>yes</c>
  <c>yes</c>
  <c>yes</c>
  <c>yes</c>

  <c>Firefox</c>
  <c>yes (*)</c>
  <c>yes</c>
  <c>no</c>
  <c>yes</c>

  <c>Internet Explorer</c>
  <c>yes (**)</c>
  <c>no</c>
  <c>yes</c>
  <c>no</c>

  <c>Konqueror</c>
  <c>yes</c>
  <c>no</c>
  <c>no</c>
  <c>no</c>

  <c>Opera</c>
  <c>yes</c>
  <c>no</c>
  <c>no</c>
  <c>no</c>

  <c>Safari</c>
  <c>no</c>
  <c>no</c>
  <c>no</c>
  <c>yes</c>
</texttable>

<t>
  (*) Does not implement the fallback behavior to "filename" described in 
  <xref target="disposition.parameter.filename"/>; a fix is planned for Firefox 5.
</t>
<t>
  (**) Starting with IE9RC, but only implements UTF-8.
</t>

</section>

</section>

<section title="Advice on Generating Content-Disposition Header Fields" anchor="advice.generating">
<t>
  To successfully interoperate with existing and future user agents, senders of
  the Content-Disposition header field are advised to:
</t>
<t>
  <list style="symbols">
    <t>Include a "filename" parameter when US-ASCII is sufficiently
    expressive.</t>
    <t>Use the 'token' form of the filename parameter only when it does not
    contain disallowed characters (e.g., spaces); in such cases, the
    quoted-string form should be used.</t>
    <t>Avoid including the percent character followed by two hexadecimal
    characters (e.g., %A9) in the filename parameter, since some existing
    implementations consider it to be an escape character, while others will
    pass it through unchanged.</t>
    <t>Avoid including the "\" character in the quoted-string form of the
    filename parameter, as escaping is not implemented by some user agents,
    and can be considered as an illegal path character.</t> 
    <t>Avoid using non-ASCII characters in the filename parameter. Although
    most existing implementations will decode them as ISO-8859-1, some
    will apply heuristics to detect UTF-8, and thus might fail on certain names.</t>
    <t>Include a "filename*" parameter where the desired filename cannot be
    expressed faithfully using the "filename" form. Note that legacy user
    agents will not process this, and will fall back to using the "filename"
    parameter's content.
    </t>
    <t>When a "filename*" parameter is sent, to also generate a "filename"
    parameter as a fallback for user agents that do not support the "filename*"
    form, if possible. This can be done by substituting characters with
    US-ASCII sequences (e.g., Unicode character point U+00E4 (LATIN SMALL
    LETTER A WITH DIARESIS) by "ae"). Note that this may not be possible in
    some locales. 
    </t>
    <t>When a "filename" parameter is included as a fallback (as per above),
    "filename" should occur first, due to parsing problems in some existing
    implementations.
    <cref anchor="fallbackbug" source="jre">
    Firefox is known to pick the wrong parameter; a bug fix is scheduled for
    Firefox 5.</cref>
    </t>
    <t>Use UTF-8 as the encoding of the "filename*" parameter, when present,
    because at least one existing implementation only implements that encoding.</t>
  </list>
</t>
<t>
  Note that this advice is based upon UA behaviour at the time of writing, and
  might be superseded. At the time of publication of this document,
  <eref target="http://purl.org/NET/http/content-disposition-tests"/> provides
  an overview of current levels of support in various implementations.
</t>
</section>

<section title="Change Log (to be removed by RFC Editor before publication)" anchor="change.log">
<t>
  Note: the issues names in the change log entries for draft-reschke-rfc2183-in-http
  refer to <eref target="http://greenbytes.de/tech/webdav/draft-reschke-rfc2183-in-http-issues.html"/>. 
</t>

<section title="Since draft-reschke-rfc2183-in-http-00">
<t> 
  Adjust terminology ("header" -&gt; "header field").
  Update rfc2231-in-http reference.
</t>
</section>

<section title="Since draft-reschke-rfc2183-in-http-01">
<t> 
  Update rfc2231-in-http reference. Actually define the "filename"
  parameter. Add internationalization considerations. 
  Add examples using the RFC 5987 encoding.
  Add overview over other approaches, plus a table reporting
  implementation status.
  Add and resolve issue "nodep2183".
  Add issues "asciivsiso",
  "deplboth", "quoted", and "registry".
</t>
</section>

<section title="Since draft-reschke-rfc2183-in-http-02">
<t>
  Add and close issue "docfallback".
  Close issues "asciivsiso", "deplboth", "quoted", and 
  "registry".
</t>
</section>

<section title="Since draft-reschke-rfc2183-in-http-03">
<t>
  Updated to be a Working Draft of the IETF HTTPbis Working Group.
</t>
</section>

<section title="Since draft-ietf-httpbis-content-disp-00" anchor="changes.since.00">
<t>
  Closed issues:
  <list style="symbols">
    <t>
      <eref target="http://tools.ietf.org/wg/httpbis/trac/ticket/242"/>:
      "handling of unknown disposition types"
    </t>
  </list>
</t>
<t>
  Slightly updated the notes about the proposed fallback behavior.
</t>
</section>

<section title="Since draft-ietf-httpbis-content-disp-01" anchor="changes.since.01">
<t>
  Various editorial improvements.
</t>
</section>

<section title="Since draft-ietf-httpbis-content-disp-02" anchor="changes.since.02">
<t>
  Closed issues:
  <list style="symbols">
    <t>
      <eref target="http://tools.ietf.org/wg/httpbis/trac/ticket/244"/>:
      "state that repeating parameters are invalid"
    </t>
    <t>
      <eref target="http://tools.ietf.org/wg/httpbis/trac/ticket/245"/>:
      "warn about %xx in filenames being misinterpreted"
    </t>
    <t>
      <eref target="http://tools.ietf.org/wg/httpbis/trac/ticket/246"/>:
      "mention control chars when talking about postprecessing the filename parameter"
    </t>
  </list>
</t>
<t>
  Update <xref target="alternatives.implementations"/>; Opera 10.63 RC 
  implements the recommended fallback behavior.
</t>
</section>

<section title="Since draft-ietf-httpbis-content-disp-03" anchor="changes.since.03">
<t>
  Closed issues:
  <list style="symbols">
    <t>
      <eref target="http://tools.ietf.org/wg/httpbis/trac/ticket/252"/>:
      "'modification-date' *is* implemented in Konq 4.5"
    </t>
    <t>
      <eref target="http://tools.ietf.org/wg/httpbis/trac/ticket/253"/>:
      "clarify what LWS means for the Content-Disp grammar"
    </t>
    <t>
      <eref target="http://tools.ietf.org/wg/httpbis/trac/ticket/258"/>:
      "Avoid passive voice in message requirements"
    </t>
    <t>
      <eref target="http://tools.ietf.org/wg/httpbis/trac/ticket/263"/>:
      "text about historical percent-decoding unclear"
    </t>
    <t>
      <eref target="http://tools.ietf.org/wg/httpbis/trac/ticket/264"/>:
      "add explanation of language tagging"
    </t>
    <t>
      <eref target="http://tools.ietf.org/wg/httpbis/trac/ticket/265"/>:
      "Clarify that C-D spec does not apply to multipart upload"
    </t>
  </list>
</t>
</section>

<section title="Since draft-ietf-httpbis-content-disp-04" anchor="changes.since.04">
<t>
  Updated implementation information (Chrome 9 implements RFC 5987, IE 9 RC implements
  it for UTF-8 only).
</t>
<t>
  Clarify who requirements are on, add a section discussing conformance
  and handling of invalid field values in general.
</t>
<t>
  Closed issues:
  <list style="symbols">
     <t>
      <eref target="http://trac.tools.ietf.org/wg/httpbis/trac/ticket/243"/>:
      "avoid stating ISO-8859-1 default for header param" (the default
      is still mentioned, but it was clarified what it applies to).
    </t>
   <t>
      <eref target="http://tools.ietf.org/wg/httpbis/trac/ticket/272"/>:
      "Path Separator Characters"
    </t>
  </list>
</t>
</section>

<section title="Since draft-ietf-httpbis-content-disp-05" anchor="changes.since.05">
<t>
  Editorial changes:
  Fixed two typos where the new Conformance section said "Content-Location" instead
  of "Content-Disposition". Cleaned up terminology ("user agent", "recipient",
  "sender", "message body", ...). Stated what the escape character for quoted-string
  is. Explained a use case for "inline" disposition type. Updated implementation
  notes with respect to the fallback behavior. 
</t>
<t>
  Added appendix "Advice on Generating Content-Disposition Header Fields".
</t>
</section>

<section title="Since draft-ietf-httpbis-content-disp-06" anchor="changes.since.06">
<t>
  Closed issues:
  <list style="symbols">
     <t>
      <eref target="http://trac.tools.ietf.org/wg/httpbis/trac/ticket/278"/>:
      "conformance language"
    </t>
  </list>
</t>
</section>

<section title="Since draft-ietf-httpbis-content-disp-07" anchor="changes.since.07">
<t>
  Rephrase the requirement about well-known file system locations, and also
  clarify that by "last path segment" we mean the actual filename.
  Added a forward reference from "invalid" to the section that defines a valid
  header field.
</t>
</section>

</section>


  </back>

</rfc>