Ejemplo
Handle Express res.format content negotiation 406 error dispatch, canonicalized err.types, unconditional Vary header, and default fallback semantics
sha256:2fa6c10475b5b6d8e09997cd54b5033b0d036a8e8a20dff8820063ebce125ae2
PUBLISHED
L3_CONTRACT_PASS
MIT-0
Evidencia de ejecución
Separamos el entorno declarado de las ejecuciones firmadas para mostrar qué se demostró.
Base de evidenciaContrato firmado aprobado
Recibos de verificación1
Nivel de verificaciónL3_CONTRACT_PASS
Entorno declarado
- Contexto de ejecución
- node
- Sistema operativo
- linux
- Arquitectura
- x64
- Runtime
- node
- Lenguaje
- node
- Gestor de paquetes
- npm
Entornos de las ejecuciones de verificación
- Contexto de ejecución
- node 22
- Sistema operativo
- linux alpine · musl
- Arquitectura
- x64
- Runtime
- node 22
- Lenguaje
- javascript
- Gestor de paquetes
- npm
- Ejecución
- container · docker
CONTAINER_RUN · compile:SKIPPED · contract:PASS · load:PASS · resolve:PASS · node-typescript@1 · 2026-08-17
Caso
- Objetivo
- Handle Express res.format content negotiation 406 error dispatch, canonicalized err.types, unconditional Vary header, and default fallback semantics HOW
- Paquetes
-
express 4.21.2
- Entorno
- node
- Creado
- 2026-08-17T06:38:16Z
Lo que suele suponerse
res.format directly renders an HTTP 406 response rather than routing a NotAcceptableError to next(), err.types preserves raw format keys like ['html'], and default handlers receive a pre-assigned Content-Type.
El autor de la muestra anotó aquí lo que un desarrollador o un modelo esperaría. El contrato de abajo es lo que realmente se ejecutó.
Contrato
- res.format routes an HTTP 406 NotAcceptableError to next() with canonicalized MIME types in err.types and unconditionally sets Vary: Accept when no registered format matches the Accept header and no default handler is provided
- res.format sets the Content-Type header to the canonical MIME type of the matched format key before executing the handler callback
- res.format wildcard matching with Accept: */* selects the first format key defined on the object and applies its canonical Content-Type
- res.format executes the default fallback handler without pre-setting Content-Type while preserving the Vary: Accept header
- res.format with an empty object forwards an HTTP 406 NotAcceptableError with an empty err.types array to next()
Archivos
- NOTES.md
- csx.json
- package-lock.json
- package.json
- test/contract.mjs
Descargar el artefacto de código fuente (tar.gz)
Seeder de origen
csx-seed
Recibos de verificación
- node 22 · linux alpine/x64 · docker · CONTAINER_RUN · compile:SKIPPED · contract:PASS · load:PASS · resolve:PASS · node-typescript@1 · 2026-08-17 · ed25519:d91480838ac982c9