Repository navigation
fix(wrapper): hold headers until request body buffering completes - #60
Merged
Merged
Conversation
Signed-off-by: zty98751 <zty98751@alibaba-inc.com>
Signed-off-by: zty98751 <zty98751@alibaba-inc.com>
Signed-off-by: johnlanni <ztywto@qq.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.
When
transformerruns before an asynchronous rate limiter, returning Continue from its header handler lets the limiter resume Envoy's shared body buffer while transformer is still buffering the upload. A real gateway reproduction forwards the original JSON upstream instead of applying the configured body transformation.Hold headers with
HeaderStopIterationonly when the current request actually uses buffered body processing, its header handler returned Continue, and it does not require Expect/Upgrade/CONNECT negotiation. HonorDontReadRequestBody, streaming selection, existing binary/encoding/WebSocket opt-outs, and explicit header actions including both StopAll variants. Complete buffered request delivery once on either DATA end-of-stream or trailers, retaining legacy fail-open reads and required-body fail-closed behavior. Update the example assertions and test-host implicit initialization for the intended header pause.Compatibility
Expect: 100-continuetoken, valid Upgrade headers, or the CONNECT method retain their original header action, including whenRequireRequestBody()is set. Only the new automatic header hold is bypassed; body settings and explicit plugin actions are unchanged. Connection/Expect values use case-insensitive complete-token matching. These compatibility paths retain the previous shared-buffer behavior and do not gain the new header barrier.ResumeHttpRequest()are still the plugin's responsibility; the wrapper does not intercept them.Verification
b06c410) and pass with the protocol exemptions. The tests preserve required body delivery and explicit Stop/StopAll actions, and check token lists and false substring matches. Independent compatibility re-review found no remaining P0/P1 in this patch.GOMAXPROCS=4 go test -p 4 -race ./pkg/...passed.GOMAXPROCS=4 go test -p 4 ./...passed in all five example modules; request-block checks both native Go and compiled Wasm, including implicit header initialization.go vet ./...passed in the root and all example modules;gofmtandgit diff --checkpassed.transformerandai-token-ratelimit, built against this SDK, passed the committed integration script on Higress Envoy 1.36.12. Companion Higress checkout:d388d06a92dd125bbe99330888690fd6deeb352f; baseline SDK:580c182.Reproduce with the committed script (requires Docker, Go, redis-server, redis-cli, and a Higress checkout):
The script runs 21 original/fixed gateway cases when a baseline SDK is supplied. It uses temporary module files, a complete-body Wasm handshake fixture, isolated loopback listeners and disabled hot restart; records results and Envoy logs; and cleans up only its own containers/processes. Runtime handshake tests verify negotiation; required-body byte delivery is checked separately in Go unit tests. This integration check is manual; the ordinary SDK tests continue to run in CI.
AI-assisted implementation and verification with OpenAI Codex.