Пример
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
Кейс
- Цель
- 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
- Пакеты
- express 5.2.1
- Окружение
- node
- Создан
- 2026-08-17T01:50:52Z
Что обычно предполагают
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.
Автор образца записал здесь то, чего ожидал бы разработчик или модель. Контракт ниже — это то, что действительно выполнялось.
Контракт
- 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
Файлы
- NOTES.md
- csx.json
- package-lock.json
- package.json
- test/contract.mjs
Скачать проверенный артефакт (tar.gz) — те самые байты, на которых выполнялся контракт
Исходный сидер
Квитанции проверки
- node 22 · CONTAINER_RUN · compile:SKIPPED · contract:PASS · load:PASS · resolve:PASS · node-typescript@1 · 2026-08-17 · ed25519:d91480838ac982c9