如何连接code在HTTP内容处理标头的文件名参数? [英] How to encode the filename parameter of Content-Disposition header in HTTP?

查看:125
本文介绍了如何连接code在HTTP内容处理标头的文件名参数?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这要强制资源的Web应用程序是的下载的而不是直接的渲染的在Web浏览器发出内容处置形式的HTTP响应头:

Web applications that want to force a resource to be downloaded rather than directly rendered in a Web browser issue a Content-Disposition header in the HTTP response of the form:

内容处置:附件;文件名=的文件名

文件名参数可以用来表明换入该资源是由浏览器下载的文件的名称。 RFC 2183 (内容处置),然而,在section 2.3 (filename参数),该文件的名称只能使用US-ASCII字符:

The filename parameter can be used to suggest a name for the file into which the resource is downloaded by the browser. RFC 2183 (Content-Disposition), however, states in section 2.3 (The Filename Parameter) that the file name can only use US-ASCII characters:

电流[RFC 2045]语法限制
  参数值(并且因此
  内容配置文件名)
  US-ASCII。我们认识到,伟大
  允许任意的可取
  字符集的文件名,但它是
  超出了本文的范围
  确定必要的机制。

Current [RFC 2045] grammar restricts parameter values (and hence Content-Disposition filenames) to US-ASCII. We recognize the great desirability of allowing arbitrary character sets in filenames, but it is beyond the scope of this document to define the necessary mechanisms.

有经验证据,不过,今天最流行的Web浏览器似乎允许非US-ASCII字符,但(对于缺乏标准)不同意的文件名的编码方案和字符集规范。问题是,那么,有什么不同的计划和受流行的浏览器采用的编码方式,如果文件名naïvefile(不带引号并在第三个字母是U + 00EF)是EN codeD插入内容处置​​头需要?

There is empirical evidence, nevertheless, that most popular Web browsers today seem to permit non-US-ASCII characters yet (for the lack of a standard) disagree on the encoding scheme and character set specification of the file name. Question is then, what are the various schemes and encodings employed by the popular browsers if the file name "naïvefile" (without quotes and where the third letter is U+00EF) needed to be encoded into the Content-Disposition header?

有关这个问题的目的,的流行的浏览器的存在:

For the purpose of this question, popular browsers being:


  • 火狐

  • 的Internet Explorer

  • Safari浏览器

  • 谷歌浏览器

  • 歌剧

推荐答案

有就是这次讨论,包括链接到浏览器测试和向后兼容性,在拟议的 RFC 5987 ,字符集和语言编码的超文本传输​​协议(HTTP)标头字段参数。

There is discussion of this, including links to browser testing and backwards compatibility, in the proposed RFC 5987, "Character Set and Language Encoding for Hypertext Transfer Protocol (HTTP) Header Field Parameters."

RFC 2183 表明,这种头应根据的RFC 2184 ,这是由 RFC 2231 废弃,通过上面的RFC草案所涵盖。

RFC 2183 indicates that such headers should be encoded according to RFC 2184, which was obsoleted by RFC 2231, covered by the draft RFC above.

这篇关于如何连接code在HTTP内容处理标头的文件名参数?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆