Search code examples
httpmime-typescontent-negotiation

Should an HTTP server respond with a more specific Content-Type than was requested?


For example, if the request was

GET /feed.xml HTTP/1.1
Host: www.nowhere123.com
Accept: application/xml

... would it be admissible for a server to respond with a header Content-Type: application/atom+xml (even though the request had Accept: application/xml), or should it serve the same body but with Content-Type: application/xml?


Solution

  • A server is allowed to ignore the header field, so yes, sending something more specific is ok. There's a reason why HTTP messages are self-descriptive. (see https://greenbytes.de/tech/webdav/rfc7231.html#rfc.section.5.3.2.p.7)