Class JavaNetSoTimeoutHttpConnectionFilter

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

public final class JavaNetSoTimeoutHttpConnectionFilter extends Object implements StreamingHttpConnectionFilterFactory
A filter that mimics SocketOptions.SO_TIMEOUT behavior on the client-side.

While TimeoutHttpRequesterFilter applies a timeout for the overall duration to receive either the response metadata (headers) or the complete reception of the response (including headers, payload body, optional trailers, as well as time to send the request), this filter applies timeout to every independent read operation: read of 100 (Continue) response, read of response headers, read of every response payload body chunk, read of optional trailers. Note that the time to send the request is not accounted. Also, if the remote server is sending a large payload body, the timeout will be applied on every chunk read, which may result in unpredictable time to read the full response if the remote slowly sends 1 byte within the timeout boundaries. Use this filter only for compatibility with classic blocking Java libraries. To protect from the described use-cases, consider also appending TimeoutHttpRequesterFilter before applying this filter in the filter chain.

This filter implements only StreamingHttpConnectionFilterFactory and therefore can be applied only at the connection level. This restriction ensures that the timeout is applied only for the response read operations (similar to SocketOptions.SO_TIMEOUT used by Java blocking API), without waiting for selecting or establishing a connection.

SocketTimeoutException (or its subtype) will be propagated when the timeout is reached.

See Also: