fix(#120): Content-Length 省略時もボディサイズ制限を適用する#133
Merged
Conversation
BaseHTTPMiddleware がバッファリングした実際のボディを読んでチェックすることで Transfer-Encoding: chunked リクエストによる制限回避を防ぐ。 Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
RequestSizeLimitMiddlewareがContent-Lengthヘッダーのみチェックしていたため、Transfer-Encoding: chunkedでヘッダーを省略すると制限が完全に回避できたawait request.body()で実際のボディを読み込んでサイズチェックするよう修正Content-Lengthがある場合は事前チェック(高速パス)も維持Content-Length値(非整数)は無視してボディチェックにフォールバックTest plan
test_small_request_passes— 既存テスト継続パスtest_oversized_request_returns_413— Content-Length あり・超過で 413test_oversized_body_without_content_length_returns_413— Content-Length なし・超過で 413(新規)test_malformed_content_length_is_tolerated— 非整数 Content-Length で 500 にならない(新規)Closes #120
🤖 Generated with Claude Code