Content Negotiation: Difference between revisions

Jump to navigation Jump to search
m
no edit summary
No edit summary
mNo edit summary
Line 4: Line 4:


== Mechanism ==
== Mechanism ==
1. When a client makes a request to a server it supplies all the formats it supports in the [[Accept Header]]: `Accept: text/html,application/xhtml+xml`.
1. When a client makes a request to a server it supplies all the formats it supports in the [[Accept Header]]: <code>Accept: text/html,application/xhtml+xml</code>.
2. The server looks at the list the client sent and excludes all formats it does not support.
2. The server looks at the list the client sent and excludes all formats it does not support.
3. If there are no common formats, the server either responds with [[406 Not Acceptable]] or it picks a fallback format like `text/html`.
3. If there are no common formats, the server either responds with [[406 Not Acceptable]] or it picks a fallback format like <code>text/html</code>.
4. If there are common formats left, the server picks the one the client marked with the highest priority.
4. If there are common formats left, the server picks the one the client marked with the highest priority.
5. The server then returns the content that matches the negotiated format.
5. The server then returns the content that matches the negotiated format.

Navigation menu