freecoding.school100% FREE · NO SIGNUP
Gateway RidgeISSUE #10 of 35

content negotiation · accept · vary

Gateway GusVSTimeout Titan
Gateway Gus saysContent negotiation lets one endpoint serve multiple formats based on the Accept header.

A client states what it wants via Accept: application/json (or XML, CSV…); the server returns that format and echoes Content-Type. The server should add Vary: Accept so caches store each format separately. Most JSON APIs only speak JSON, but negotiation matters for APIs serving multiple representations of the same resource.

Power-ups you unlock

Timeout Titan attacks — common mistakes

Boss battleShow requests for the same resource as JSON and as CSV.

Example code

<!doctype html><html><head><meta charset="utf-8"></head>
<body style="background:#06040d;color:#e6e0ff;font-family:monospace;padding:20px"><pre>GET /report  Accept: application/json → JSON
GET /report  Accept: text/csv          → CSV
(server adds Vary: Accept)</pre></body></html>
▶ Open the interactive comic issue
‹ Validation · Request Shape · 400 Vs 422Compression · Gzip · Brotli · Zstd ›