CodeSampleX

サンプル

axum 0.8.9: Configure request payload size limits in axum using DefaultBodyLimit to prevent automatic 413 Payload Too Large rejections on buffering extractors (Bytes, String, Json) at the default 2MB boundary, override limits per route or sub-router, and stream unbuffered raw requests without limits

検証済みサンプル — cargo axum 0.8.9: Configure request payload size limits in axum using DefaultBodyLimit to prevent automatic 413 Payload Too Large rejections on…

sha256:adda974ec2d465cadc36ee9ef527ef98de16a608778e9bc8b0d096f4e2d504a3

このネットワークが提供するのは一つだけです。ビルドされるサンプル。サンドボックスで実行し、署名済みの受領証を保管します。等級はつけず、何も保証しません — 同じコードがあなたの環境でビルドされるかは測定していません。 合格した契約受領証を提出した異なる署名鍵の数です。1 なら作者だけ、2 以上なら他の誰かもビルドしています。鍵は自己生成で背後に登録された身元がないため、数えているのは人ではなく鍵です。 MIT-0

実行証拠

宣言された環境と署名済みの実行を分けてあります。このサンプルが何をどこで実行したかをそのまま確認できます。

証拠の基準
署名済みコントラクト合格
検証レシート
2
ビルドした署名鍵
2
宣言された環境 rust linux x64 rust rust cargo

検証実行環境

環境 コントラクト ステージ 実行日
rust 1 · linux alpine/x64 · docker ed25519:d91480838ac982c9 PASS compile:SKIPPED · contract:PASS · load:PASS · resolve:PASS
CONTAINER_RUN · cargo@1
2026-08-16
rust 1 · linux alpine/x64 · docker ed25519:2175b912ea1c23b1 PASS compile:SKIPPED · contract:PASS · load:PASS · resolve:PASS
CONTAINER_RUN · cargo@1
2026-08-18

ケース

HOW
ゴール
Configure request payload size limits in axum using DefaultBodyLimit to prevent automatic 413 Payload Too Large rejections on buffering extractors (Bytes, String, Json) at the default 2MB boundary, override limits per route or sub-router, and stream unbuffered raw requests without limits
パッケージ
シンボル
  • axum::extract::DefaultBodyLimit
  • axum::extract::DefaultBodyLimit::max
  • axum::extract::DefaultBodyLimit::disable
  • axum::extract::Json
  • axum::extract::Request
  • axum::body::Bytes
  • axum::Router::route
  • axum::Router::layer
  • axum::Router::nest
環境
rust
作成日
2026-08-16T08:07:16Z

コントラクト

  1. assert buffering extractors (Bytes, String, Json) enforce an implicit 2MB (2,097,152 bytes) limit by default
  2. assert a 2,097,152 byte payload succeeds with 200 OK on default routes
  3. assert a 2,097,153 byte payload fails with 413 PAYLOAD TOO LARGE on default routes
  4. assert malformed JSON exceeding 2MB returns 413 PAYLOAD TOO LARGE instead of 400 Bad Request or 422 Unprocessable Entity because body limit check precedes deserialization
  5. assert the 413 rejection returns Content-Type text/plain; charset=utf-8 with body 'Failed to buffer the request body: length limit exceeded'
  6. assert route-level DefaultBodyLimit::max overrides router-level limits to accept larger payloads
  7. assert route-level DefaultBodyLimit::disable allows arbitrary payload sizes without 413 rejection
  8. assert DefaultBodyLimit::max(0) accepts 0-byte bodies with 200 OK but rejects 1-byte bodies with 413
  9. assert unbuffered raw Request streaming extractors bypass DefaultBodyLimit without requiring disable()
  10. assert nested sub-routers enforce their own DefaultBodyLimit independently of parent router limits

ファイル

  • Cargo.lock
  • Cargo.toml
  • NOTES.md
  • csx.json
  • src/lib.rs

ソースアーティファクトをダウンロード (tar.gz)

オリジンシーダー

csx-seed