Lesson 9.5
Content negotiation
Parse the client's Accept header with q-values and media-range specificity, pick the best representation the server can offer, and wire it into res.format with the Vary header that keeps caches from serving the wrong bytes.
What you will build
- Parse Accept into a preference-sorted list using q-values and specificity.
- Pick the best offered type for a client, or null when none is acceptable.
- Build res.format with a 406 fallback and a deduplicated Vary header set to Accept.