http - 在 HTTP 响应 header 中使用 content-disposition

标签 http http-headers httpwebresponse httpresponse content-disposition

我发现以下 asp.net 代码在从数据库提供文件时非常有用:

Response.AppendHeader("content-disposition", "attachment; filename=" + fileName);

这让用户可以将文件保存到他们的计算机上,然后决定如何使用它,而不是浏览器尝试使用该文件。

content-disposition 响应头还能做些什么?

最佳答案

请注意 RFC 6266取代下面引用的 RFC。 Section 7概述了一些相关的安全问题。

content-disposition 头的权限是RFC 1806RFC 2183.人们还设计了content-disposition hacking.请务必注意,content-disposition header 不是 HTTP 1.1 标准的一部分。

HTTP 1.1 标准 ( RFC 2616 ) 还提到了内容处置可能带来的安全副作用:

15.5 Content-Disposition Issues

RFC 1806 [35], from which the often implemented Content-Disposition
(see section 19.5.1) header in HTTP is derived, has a number of very
serious security considerations. Content-Disposition is not part of
the HTTP standard, but since it is widely implemented, we are
documenting its use and risks for implementors. See RFC 2183 [49]
(which updates RFC 1806) for details.

关于http - 在 HTTP 响应 header 中使用 content-disposition,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1012437/

相关文章:

http - MantisBT 图片预览大小设置

node.js - 无法使用 Express 4 路由器获取 Content-Type header

c# - 发送 POST HttpWebRequest 并且不需要接收响应

HTTP If-Modified-Since 以毫秒为单位

php - file_get_contents() 修改后的 HTTP header 返回垃圾 html 输出

c# - 尝试使用 HttpWebRequest 获取身份验证 cookie

apache - 减少服务器响应时间 - debian 7 上的 apache2

php - 浏览器忽略来自 ajax 响应的 header 刷新

java - 非 servlet Java HTTP 服务器

Angular 5 HttpClient HttpTestingController 测试报错路径