HTTP Upgrade-Insecure-Requests Request header向服务器发送一个信号,表明客户端偏好加密且经过认证的响应,并且客户端能够成功处理 upgrade-insecure-requests CSP 指令。
<table class="properties"> <tbody> <tr> <th scope="row">标头类型</th> <td>Request header</td> </tr> <tr> <th scope="row">Forbidden request header</th> <td>否</td> </tr> </tbody> </table>
语法
Upgrade-Insecure-Requests: <boolean>
指令
<boolean>- :
1表示“true”,并且是该字段唯一有效的值。
- :
示例
使用 Upgrade-Insecure-Requests
客户端的请求会向服务器表明它支持 upgrade-insecure-requests 的升级机制:
GET / HTTP/1.1
Host: example.com
Upgrade-Insecure-Requests: 1
服务器现在可以将请求重定向到站点的安全版本。可以使用 Vary 标头,以避免缓存向不支持升级机制的客户端提供相同的站点内容。
Location: https://example.com/
Vary: Upgrade-Insecure-Requests
规范
浏览器兼容性
参见
- Content-Security-Policy
- CSP upgrade-insecure-requests 指令
- HTTP 缓存:Vary 和 Vary 标头
来源:MDN Web Docs / Mozilla 贡献者 · 作者与贡献记录 · CC BY-SA 2.5。离线整理了版式、链接和媒体显示。
