HTTP 服务器是否应该使用比请求更具体的 Content-Type 进行响应?
Should an HTTP server respond with a more specific Content-Type than was requested?
例如,如果请求是
GET /feed.xml HTTP/1.1
Host: www.nowhere123.com
Accept: application/xml
... 是否允许服务器以 [=20=] Content-Type: application/atom+xml
响应(即使请求有 Accept: application/xml
),还是应该提供相同的 body 但是 Content-Type: application/xml
?
允许服务器忽略 header 字段,所以是的,发送更具体的内容是可以的。 HTTP 消息 self-descriptive 是有原因的。 (参见 https://greenbytes.de/tech/webdav/rfc7231.html#rfc.section.5.3.2.p.7)
例如,如果请求是
GET /feed.xml HTTP/1.1
Host: www.nowhere123.com
Accept: application/xml
... 是否允许服务器以 [=20=] Content-Type: application/atom+xml
响应(即使请求有 Accept: application/xml
),还是应该提供相同的 body 但是 Content-Type: application/xml
?
允许服务器忽略 header 字段,所以是的,发送更具体的内容是可以的。 HTTP 消息 self-descriptive 是有原因的。 (参见 https://greenbytes.de/tech/webdav/rfc7231.html#rfc.section.5.3.2.p.7)