Exemplo
Handle Express request header evaluation boundaries across req.is body presence, req.accepts zero-weight quality factors, req.range numeric sentinel codes, and req.get empty-string validation
sha256:e74ad98b97d3ae7856fa4fd5b676002a0036a58f77d64b678a2ecb9d6561a100
PUBLISHED
L3_CONTRACT_PASS
MIT-0
Caso
- Objetivo
- Handle Express request header evaluation boundaries across req.is body presence, req.accepts zero-weight quality factors, req.range numeric sentinel codes, and req.get empty-string validation HOW
- Pacotes
- express 5.2.1
- Ambiente
- node
- Criado
- 2026-08-17T01:50:52Z
O que costuma-se supor
req.is('json') evaluates the Content-Type header directly regardless of whether a body was sent, req.range() returns empty arrays or null on invalid or unsatisfiable byte ranges, and req.accepts() returns true for any media type mentioned in the Accept header.
O autor da amostra registrou aqui o que um desenvolvedor ou um modelo esperaria. O contrato abaixo é o que de fato rodou.
Contrato
- req.is('json') returns null when the request lacks body headers such as Content-Length or Transfer-Encoding even if Content-Type application/json is present, returning the matched type string only when a body is actually transmitted
- req.accepts('json') returns false when the Accept header sets application/json;q=0, and multi-type negotiation req.accepts(['json', 'html']) skips zero-weight candidates to select acceptable alternatives
- req.acceptsEncodings() returns false for all encodings when Accept-Encoding is set to *;q=0
- req.range(size) returns numeric sentinel -1 for unsatisfiable byte ranges and numeric sentinel -2 for malformed range syntax rather than null or an empty array
- req.range(size) returns undefined when the Range header is omitted, and parses valid suffix ranges such as bytes=-200 relative to the provided total size
- req.get('') and req.get(null) throw TypeError requiring a non-empty string header name, while req.get('referrer') automatically aliases to the HTTP Referer header
Arquivos
- NOTES.md
- csx.json
- package-lock.json
- package.json
- test/contract.mjs
Baixar o artefato verificado (tar.gz) — exatamente os bytes contra os quais o contrato rodou
Seeder de origem
Recibos de verificação
- node 22 · CONTAINER_RUN · compile:SKIPPED · contract:PASS · load:PASS · resolve:PASS · node-typescript@1 · 2026-08-17 · ed25519:d91480838ac982c9