Interface ResponseBodyControl
-
- All Known Implementing Classes:
NettyResponseBodyControl
public interface ResponseBodyControlControls transport reads for a response body.The control is thread-safe and remains valid until its response completes. Calls made after completion have no effect.
A control is also supplied when the final response headers end the response without a body. In that case,
suspend()cannot defer completion: the control becomes inactive whenAsyncHandler.onResponseBodyStart(ResponseBodyControl)returns, and later calls have no effect.- Since:
- 3.0.14
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description voidcancel()Stops processing the response body.voidresume()Resumes requesting response bytes after a call tosuspend().voidsuspend()Stops requesting additional response bytes from the transport.
-
-
-
Method Detail
-
suspend
void suspend()
Stops requesting additional response bytes from the transport. Body parts that were already read may still be delivered to theAsyncHandler. If the final response headers already ended the response, this call has no effect on completion.While reads are suspended, the read timeout is paused but the request timeout remains active. If the request timeout is disabled, failing to resume or cancel the response can retain its transport resources indefinitely.
For HTTP/2, while any response on a connection is suspended, AHC continues returning connection-level flow-control credit so a suspended stream cannot block sibling streams. Responses on connections with no active suspension retain the normal shared connection-window bound. The per-stream window always applies, so roughly
AsyncHttpClientConfig.getHttp2InitialWindowSize()bytes can be queued for each suspended stream. Aggregate buffering during suspension can therefore scale with the number of concurrent streams. Once the last suspension ends, normal connection accounting resumes; credit already returned and data already queued cannot be revoked. Applications can bound buffering withAsyncHttpClientConfig.getHttp2InitialWindowSize()andAsyncHttpClientConfig.getHttp2MaxConcurrentStreams().
-
resume
void resume()
Resumes requesting response bytes after a call tosuspend().
-
cancel
void cancel()
Stops processing the response body. As withAsyncHandler.State.ABORT, the handler is completed normally. ReturningABORTis the preferred way to stop from within anAsyncHandlercallback; this method is intended for cancellation after the callback has returned, including from another thread.
-
-