Content Negotiation
Negociación de contenido
La negociación de contenido es cómo HTTP selecciona una versión de un recurso según las preferencias del cliente y los formatos disponibles en el servidor.
Otro ejemplo
Una API de reportes envía `application/json` o `text/csv` según `Accept`. Devuelve 406 si ninguno funciona y agrega `Vary: Accept`. Esto evita que una caché envíe CSV a un cliente JSON. El idioma se elige por separado, y cada respuesta tiene un `Content-Type` claro.
Partes principales
- 01preferencias del cliente
- 02Representaciones disponibles
- 03Respuesta seleccionada y Vary
Úsalo cuando
Utilice encabezados de solicitud estándar cuando un recurso realmente tenga versiones diferentes de medios, idioma, codificación o preferencias.
No lo uses cuando
No cree versiones que las cachés no puedan diferenciar. No ignore silenciosamente un tipo de medio requerido que el servidor no soporta.
Nombre usado en código
Accept / Accept-Language / Accept-Encoding + Content-Type / Content-Language + Vary Antes de lanzarlo
Check contracts and invariants, authorization, and input limits. Test retries, one-time effects, timeouts, and partial failures. Verify data integrity, compatibility, monitoring, recovery, and rollback.
Outcome: Complete the task with Negociación de contenido (Content Negotiation). User context: Una API de reportes envía `application/json` o `text/csv` según `Accept`. Devuelve 406 si ninguno funciona y agrega `Vary: Accept`. Esto evita que una caché envíe CSV a un cliente JSON. El idioma se elige por separado, y cada respuesta tiene un `Content-Type` claro. Technical concept or control: Negociación de contenido (Content Negotiation). Why it fits: Utilice encabezados de solicitud estándar cuando un recurso realmente tenga versiones diferentes de medios, idioma, codificación o preferencias. Do not use it when: No cree versiones que las cachés no puedan diferenciar. No ignore silenciosamente un tipo de medio requerido que el servidor no soporta. Engineering requirements: Define inputs, outputs, contracts, and rules that must always hold. Set authorization and input checks. Define failures, timeouts, retries, one-time effects, data moves, and compatibility limits. Operations: Add useful signals and logs that hide sensitive data. Set capacity limits and write an operator guide. Test recovery and rollback. Acceptance criteria: Contract and failure-path tests pass. Data and authorization rules still hold during retries and partial failures. Check performance limits, monitoring, recovery, and rollback. Evidence and limits (evidence boundary): El estándar cubre únicamente el alcance listado. No elige el estilo visual, la decisión del producto ni el ejemplo de Vibulary. Unknowns to confirm: Where the code runs, data stores, traffic shape, consistency needs, and the security boundary. Also confirm the compatibility period, service goals, and rollback limits.
Revisa esta petición
Review how Negociación de contenido (Content Negotiation) is used now. Definition: La negociación de contenido es cómo HTTP selecciona una versión de un recurso según las preferencias del cliente y los formatos disponibles en el servidor. Release checks: Check contracts and invariants, authorization, and input limits. Test retries, one-time effects, timeouts, and partial failures. Verify data integrity, compatibility, monitoring, recovery, and rollback. Before changing code, list the evidence, gaps, severity, and the smallest safe fix.