Movatterモバイル変換


[0]ホーム

URL:


  1. 面向开发者的 Web 技术
  2. HTTP
  3. 参考
  4. HTTP 响应状态码
  5. 506 Variant Also Negotiates

此页面由社区从英文翻译而来。了解更多并加入 MDN Web Docs 社区。

View in EnglishAlways switch to English

506 Variant Also Negotiates

HTTP506 Variant Also Negotiates服务端错误响应状态码在内容协商过程中,当选择资源的过程中出现递归循环时返回。

代理驱动型内容协商使客户端和服务器能够在服务器拥有多个资源变体时,共同决定最佳的资源变体。由于服务器配置错误导致在创建响应时出现循环引用,服务器发送了506 状态码。

由于缺乏关于客户端如何自动选择响应的标准,以及额外的往返交互会减慢客户端与服务器的交互速度,这种机制很少被使用。服务端驱动型内容协商更为常见,其中服务器会根据请求标头(例如Accept-LanguageAccept 等)直接为客户端选择最合适的资源。

状态

http
506 Variant Also Negotiates

示例

带有变体的资源

在以下示例中,客户端使用Accept-Language 请求标头请求一个fr 语言环境的页面。可以使用 curl 来执行此操作:

bash
curl  -H "Negotiate: trans" -H "Accept-Language: fr;" http://example.com/index

这将生成以下请求:

http
GET /index HTTP/1.1Host: example.comUser-Agent: curl/8.7.1Accept: */*Negotiate: transAccept-Language: fr

由于服务器配置错误,fr 的变体响应指向了一个类型映射,该映射本身会触发透明协商。服务器可以在发送选择响应之前,通过TCN 标头的存在来检测此情况:

http
HTTP/1.1 506 Variant Also NegotiatesDate: Mon, 22 Jul 2024 10:00:00 GMTServer: Apache/2.4.41 (Unix)Content-Type: text/html; charset=UTF-8Content-Length: 233TCN: listVary: negotiate,accept-languageAlternates: {"index.html.en" 1 {type text/html} {language en} {length 48}}, {"another-map.html.fr.map" 1 {type text/html} {language fr} {length 45}}}}<html><head>  <title>506 Variant Also Negotiates</title></head><body>  <h1>变体也参与协商</h1>  <p>请求资源的一个变体本身是一个可协商的资源。这表明存在配置错误。</p></body></html>

规范

Specification
RFC 2295
# section-8.1

参见

Help improve MDN

Learn how to contribute

This page was last modified on byMDN contributors.


[8]ページ先頭

©2009-2026 Movatter.jp