Repository navigation
fix(http2): PATCH/DELETEなど本文付きリクエストでもcontent-lengthを付与する - #276
Merged
funa-tk merged 1 commit intoOct 22, 2026
Merged
Conversation
…g methods HeadersFrame.encodeFromHttp() only re-added the content-length header (and passed a non-zero contentLength to MetaData.Request) for POST and PUT. For other body-bearing methods such as PATCH and DELETE, contentLength stayed 0, so the reconstructed HTTP/2 request declared a zero-length body while a non-empty DATA frame followed. Strict upstreams reject this mismatch with 400 Bad Request, while the same request over HTTP/1.1 succeeds because it keeps the original Content-Length. Handle every non-GET/HEAD method the same way, and add a regression test that encodes a PATCH with a body and checks the declared length. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
toku-sa-n
marked this pull request as ready for review
October 22, 2026 10:42
funa-tk
approved these changes
Oct 22, 2026
funa-tk
left a comment
Contributor
There was a problem hiding this comment.
eclipse.orgが落ちててフォーマットのテストがチェックが通っていませんが、内容は問題ないですので、マージさせていただきます。
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.
HTTP/2で本文付きのPATCHやDELETEを中継すると、上流のサーバが400 Bad Requestを返す問題を修正しました。
原因
HeadersFrame.encodeFromHttp()でcontent-lengthを付け直す(MetaData.Requestに本文長を渡す)対象が、POSTとPUTだけになっていました。PATCHやDELETEはどちらの分岐にも入らず、本文長が0のまま渡されます。そのため、ヘッダでは本文長0と宣言しながら、実際には空でないDATAフレームを送る、という食い違った状態になっていました。厳格なサーバはこれを不正なリクエストとして400で拒否します。HTTP/1.1ではこの経路を通らず元のContent-Lengthがそのまま使われるので、同じリクエストでも成功します。変更内容
HeadersFrameTestに追加しました。修正前のコードではこのテストが失敗することを確認しています。補足
本文のないDELETEなどにも
content-length: 0が付くようになります。By placing an "x" in the box, I hereby understand, accept and agree to be bound by the terms and conditions of the Contribution License Agreement.
🤖 Generated with Claude Code