サンプル
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