Class NettyResponseBodyControl
- java.lang.Object
-
- org.asynchttpclient.netty.NettyResponseBodyControl
-
- All Implemented Interfaces:
ResponseBodyControl
@Internal public final class NettyResponseBodyControl extends Object implements ResponseBodyControl
Netty implementation ofResponseBodyControl.
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidcancel()Stops processing the response body.static voidcomplete(NettyResponseFuture<?> future)static NettyResponseBodyControlcreate(NettyResponseFuture<?> future, io.netty.channel.Channel channel, Runnable suspensionStartedAction, Runnable suspensionEndedAction, Runnable resumeAction, Consumer<Boolean> cancelAction)static NettyResponseBodyControlcreate(NettyResponseFuture<?> future, io.netty.channel.Channel channel, Runnable resumeAction, Consumer<Boolean> cancelAction)static voiddiscardForChannelClose(NettyResponseFuture<?> future, io.netty.channel.Channel channel)static booleanisSuspended(NettyResponseFuture<?> future)Returns whether response reads forfutureare suspended by its current response body control.static booleanisSuspended(NettyResponseFuture<?> future, io.netty.channel.Channel channel)Returns whetherfutureis suspended onchannel.static voidmarkBodyFullyRead(NettyResponseFuture<?> future)Records that the complete HTTP/1.1 response has reached the client before its terminal callbacks run.voidresume()Resumes requesting response bytes after a call toResponseBodyControl.suspend().voidsuspend()Stops requesting additional response bytes from the transport.
-
-
-
Method Detail
-
create
public static NettyResponseBodyControl create(NettyResponseFuture<?> future, io.netty.channel.Channel channel, Runnable resumeAction, Consumer<Boolean> cancelAction)
-
create
public static NettyResponseBodyControl create(NettyResponseFuture<?> future, io.netty.channel.Channel channel, Runnable suspensionStartedAction, Runnable suspensionEndedAction, Runnable resumeAction, Consumer<Boolean> cancelAction)
-
complete
public static void complete(NettyResponseFuture<?> future)
-
discardForChannelClose
public static void discardForChannelClose(NettyResponseFuture<?> future, io.netty.channel.Channel channel)
-
isSuspended
public static boolean isSuspended(NettyResponseFuture<?> future)
Returns whether response reads forfutureare suspended by its current response body control.
-
isSuspended
public static boolean isSuspended(NettyResponseFuture<?> future, io.netty.channel.Channel channel)
Returns whetherfutureis suspended onchannel.
-
markBodyFullyRead
public static void markBodyFullyRead(NettyResponseFuture<?> future)
Records that the complete HTTP/1.1 response has reached the client before its terminal callbacks run.
-
suspend
public void suspend()
Description copied from interface:ResponseBodyControlStops 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().- Specified by:
suspendin interfaceResponseBodyControl
-
resume
public void resume()
Description copied from interface:ResponseBodyControlResumes requesting response bytes after a call toResponseBodyControl.suspend().- Specified by:
resumein interfaceResponseBodyControl
-
cancel
public void cancel()
Description copied from interface:ResponseBodyControlStops 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.- Specified by:
cancelin interfaceResponseBodyControl
-
-