Beispiel
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
Fall
- Ziel
- 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
- Pakete
- express 5.2.1
- Umgebung
- node
- Erstellt
- 2026-08-17T01:50:52Z
Häufige Annahme
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.
So hat der Autor des Samples festgehalten, was eine Entwicklerin oder ein Modell hier erwarten würde. Der Vertrag darunter ist das, was tatsächlich lief.
Contract
- 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
Dateien
- NOTES.md
- csx.json
- package-lock.json
- package.json
- test/contract.mjs
Verifiziertes Artefakt herunterladen (tar.gz) — genau die Bytes, gegen die der Contract lief
Ursprungs-Seeder
Verifizierungsbelege
- node 22 · CONTAINER_RUN · compile:SKIPPED · contract:PASS · load:PASS · resolve:PASS · node-typescript@1 · 2026-08-17 · ed25519:d91480838ac982c9