Class PayloadSizeLimitingHttpServiceFilter
- All Implemented Interfaces:
HttpExecutionStrategyInfluencer,StreamingHttpServiceFilterFactory,ExecutionStrategyInfluencer<HttpExecutionStrategy>
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.
-
Constructor Summary
ConstructorsConstructorDescriptionPayloadSizeLimitingHttpServiceFilter(int maxRequestPayloadSize) Create a new instance. -
Method Summary
Modifier and TypeMethodDescriptioncreate(StreamingHttpService service) Create aStreamingHttpServiceFilterusing the providedStreamingHttpService.Return anExecutionStrategythat describes the offloads required by the influencer.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface io.servicetalk.http.api.HttpExecutionStrategyInfluencer
influenceStrategy
-
Constructor Details
-
PayloadSizeLimitingHttpServiceFilter
public PayloadSizeLimitingHttpServiceFilter(int maxRequestPayloadSize) Create a new instance.- Parameters:
maxRequestPayloadSize- The maximum request payload size allowed.
-
-
Method Details
-
create
Description copied from interface:StreamingHttpServiceFilterFactoryCreate aStreamingHttpServiceFilterusing the providedStreamingHttpService.- Specified by:
createin interfaceStreamingHttpServiceFilterFactory- Parameters:
service-StreamingHttpServiceto filter- Returns:
StreamingHttpServiceFilterusing the providedStreamingHttpService.
-
requiredOffloads
Description copied from interface:HttpExecutionStrategyInfluencerReturn anExecutionStrategythat describes the offloads required by the influencer.The provided default implementation requests offloading of all operations. Implementations that require no offloading should be careful to return
HttpExecutionStrategies.offloadNone()rather thanHttpExecutionStrategies.offloadNever(). Implementations should avoid returningHttpExecutionStrategies.defaultStrategy(), instead returning the strategy they require orHttpExecutionStrategies.offloadAll()if offloading for all paths is required (safe default).- Specified by:
requiredOffloadsin interfaceExecutionStrategyInfluencer<HttpExecutionStrategy>- Specified by:
requiredOffloadsin interfaceHttpExecutionStrategyInfluencer- Returns:
- the
ExecutionStrategyrequired by the influencer.
-