Class PayloadSizeLimitingHttpServiceFilter

java.lang.Object
io.servicetalk.http.utils.PayloadSizeLimitingHttpServiceFilter
All Implemented Interfaces:
HttpExecutionStrategyInfluencer, StreamingHttpServiceFilterFactory, ExecutionStrategyInfluencer<HttpExecutionStrategy>

public final class PayloadSizeLimitingHttpServiceFilter extends Object implements StreamingHttpServiceFilterFactory
Limits the request payload size. The filter will throw an exception which may result in stream/connection closure. A PayloadTooLargeException will be thrown when the maximum payload size is exceeded. The Content-Length request header (when present) is inspected before the body is read so oversized requests that declare their size fail early; otherwise the streaming body is bounded as bytes arrive.

This is independent of the server's default maxAggregatedPayloadSize limit, which bounds the fully-decoded payload at aggregation time. This filter bounds bytes at its position in the chain (so it can run before a decompressor to reject oversized wire bodies early); where both are configured, both apply. Because maxAggregatedPayloadSize only bounds aggregation performed by ServiceTalk, this filter is also the way to bound a body that is buffered further up the stack, such as by the JAX-RS entity readers of a streaming Jersey router.