Exemple
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
Cas
- Objectif
- 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
- Paquets
- express 5.2.1
- Environnement
- node
- Créé
- 2026-08-17T01:50:52Z
Ce que l'on suppose souvent
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.
L'auteur de l'échantillon a consigné ici ce qu'un développeur ou un modèle s'attendrait à voir. Le contrat ci-dessous est ce qui s'est réellement exécuté.
Contrat
- 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
Fichiers
- NOTES.md
- csx.json
- package-lock.json
- package.json
- test/contract.mjs
Télécharger l'artefact vérifié (tar.gz) — les octets exacts sur lesquels le contrat s'est exécuté
Seeder d'origine
Reçus de vérification
- node 22 · CONTAINER_RUN · compile:SKIPPED · contract:PASS · load:PASS · resolve:PASS · node-typescript@1 · 2026-08-17 · ed25519:d91480838ac982c9