跳到主要内容

5. Examples (示例)

指示 UA 显示 "save as" 对话框, 并使用 filename "example.html":

Content-Disposition: Attachment; filename=example.html

指示 UA 表现得像 Content-Disposition header field 不存在一样, 但记住 filename "an example.html", 以供后续保存操作使用:

Content-Disposition: INLINE; FILENAME= "an example.html"

Note: 这里使用 quoted-string 形式, 以便包含空格字符.

指示 UA 显示 "save as" 对话框, 并使用包含 Unicode 字符 U+20AC (EURO SIGN) 的 filename:

Content-Disposition: attachment;
filename*= UTF-8''%e2%82%ac%20rates

这里还使用 [RFC5987] 中定义的编码对非 ISO-8859-1 字符进行编码.

此示例与上面的示例相同, 但增加了 "filename" 参数, 以兼容未实现 RFC 5987 的 user agent:

Content-Disposition: attachment;
filename="EURO rates";
filename*=utf-8''%e2%82%ac%20rates

Note: 不支持 RFC 5987 编码的那些 user agent 会在 "filename*" 出现在 "filename" 之后时忽略 "filename*".