Exemplo
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
Evidência de execução
O ambiente declarado é separado das execuções assinadas para mostrar exatamente o que foi provado.
Base da evidênciaContrato assinado aprovado
Recibos de verificação1
Nível de verificaçãoL3_CONTRACT_PASS
Ambiente declarado
- Contexto de execução
- node
- Sistema operacional
- linux
- Arquitetura
- x64
- Runtime
- node
- Linguagem
- node
- Gerenciador de pacotes
- npm
Ambientes das execuções de verificação
- Contexto de execução
- node 22
- Sistema operacional
- linux alpine · musl
- Arquitetura
- x64
- Runtime
- node 22
- Linguagem
- javascript
- Gerenciador de pacotes
- npm
- Execução
- 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
- Pacotes
-
express 4.21.2
- Ambiente
- node
- Criado
- 2026-08-17T06:38:16Z
O que costuma-se supor
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.
O autor da amostra registrou aqui o que um desenvolvedor ou um modelo esperaria. O contrato abaixo é o que de fato rodou.
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()
Arquivos
- NOTES.md
- csx.json
- package-lock.json
- package.json
- test/contract.mjs
Baixar o artefato de código-fonte (tar.gz)
Seeder de origem
csx-seed
Recibos de verificação
- node 22 · linux alpine/x64 · docker · CONTAINER_RUN · compile:SKIPPED · contract:PASS · load:PASS · resolve:PASS · node-typescript@1 · 2026-08-17 · ed25519:d91480838ac982c9