Problem
The StreamBuffer pre-read in stream_buffer.rs consumes the downstream request body via read_request_body() so that body filters can promote headers before the request-phase pipeline runs (e.g. json_body_field extracting a model name).
After the pre-read, Pingora's body forwarding loop never calls request_body_filter because is_body_done() returns true. The pre-read body stored in ctx.pre_read_body is never drained to upstream.
Current Workaround
In #62 I added enable_retry_buffering() before the pre-read so that
Pingora's retry buffer captures the body data.
Pingora then uses get_retry_buffer() to replay the body to upstream via send_body_to_pipe.
However, Pingora's retry buffer is capped at 64 KiB via (BODY_BUF_LIMIT in pingora-core).
Bodies exceeding that limit are silently truncated and will not be forwarded to upstream.
Proposed Fix
Add an upstream Pingora API (e.g. set_preread_body()) that feeds Pingora's body forwarding loop without the 64 KiB retry buffer limit. Or, if we still need to enable retry buffering, ensure that we have a way to up the limit. @shaneutt mentioned that this can be resolved upstream.
Impact
Any StreamBuffer filter that processes request bodies larger than 64 KiB will silently drop the body when forwarding to upstream. Currently only json_body_field uses StreamBuffer, and its integration tests use start_header_echo_backend which does not read the request body, masking the issue.
Problem
The
StreamBufferpre-read instream_buffer.rsconsumes the downstream request body viaread_request_body()so that body filters can promote headers before the request-phase pipeline runs (e.g.json_body_fieldextracting a model name).After the pre-read, Pingora's body forwarding loop never calls
request_body_filterbecauseis_body_done()returnstrue. The pre-read body stored inctx.pre_read_bodyis never drained to upstream.Current Workaround
In #62 I added
enable_retry_buffering()before the pre-read so thatPingora's retry buffer captures the body data.
Pingora then uses
get_retry_buffer()to replay the body to upstream viasend_body_to_pipe.However, Pingora's retry buffer is capped at 64 KiB via (
BODY_BUF_LIMITinpingora-core).Bodies exceeding that limit are silently truncated and will not be forwarded to upstream.
Proposed Fix
Add an upstream Pingora API (e.g.
set_preread_body()) that feeds Pingora's body forwarding loop without the 64 KiB retry buffer limit. Or, if we still need to enable retry buffering, ensure that we have a way to up the limit. @shaneutt mentioned that this can be resolved upstream.Impact
Any
StreamBufferfilter that processes request bodies larger than 64 KiB will silently drop the body when forwarding to upstream. Currently onlyjson_body_fieldusesStreamBuffer, and its integration tests usestart_header_echo_backendwhich does not read the request body, masking the issue.