AlinsRan opened a new pull request, #13356: URL: https://github.com/apache/apisix/pull/13356
## Summary When multiple `post_arg.*` variables are evaluated in a single request (e.g. `vars` expressions in route matching), each access independently triggers a full body read + `json.decode` cycle. For large request bodies at high QPS, this causes unnecessary repeated CPU and memory overhead. ## Changes Split `get_parsed_request_body` into two layers: - `_get_parsed_request_body(ctx)` — pure parsing logic, no side effects - `get_parsed_request_body(ctx)` — wrapper that adds a per-request ctx cache On the first access, the decoded table is stored in `ctx._parsed_request_body`. Subsequent accesses to different `post_arg.*` keys within the same request reuse the cached result, so `json.decode` runs at most once per request. Errors are intentionally **not cached**: plugins may call `ngx.req.set_body_data()` in later phases, so a transient parse failure should not be permanently frozen for the request lifetime. ## Tests Added TEST 3/4 in `t/core/ctx3.t`: a route with three different `post_arg.*` keys, verifying all fields are read correctly and that the `reuse parsed request body from ctx cache` debug log appears exactly twice (for the second and third key accesses). -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
