@Override public void write(ChannelHandlerContext ctx, Object msg, ChannelPromise promise) throws Exception { // Allow writing with void promise if handler is only configured for read timeout events. if (writerIdleTimeNanos > 0 || allIdleTimeNanos > 0) { ctx.write(msg, promise.unvoid()).addListener(writeListener); } else { ctx.write(msg, promise); } }
@Override public void write(ChannelHandlerContext ctx, Object msg, ChannelPromise promise) throws Exception { if (timeoutNanos > 0) { promise = promise.unvoid(); scheduleTimeout(ctx, promise); } ctx.write(msg, promise); }
@Override public void write(ChannelHandlerContext ctx, Object msg, ChannelPromise promise) throws Exception { // Allow writing with void promise if handler is only configured for read timeout events. if (writerIdleTimeNanos > 0 || allIdleTimeNanos > 0) { ctx.write(msg, promise.unvoid()).addListener(writeListener); } else { ctx.write(msg, promise); } }
@Override public void write(ChannelHandlerContext ctx, Object msg, ChannelPromise promise) throws Exception { if (timeoutNanos > 0) { promise = promise.unvoid(); scheduleTimeout(ctx, promise); } ctx.write(msg, promise); }
@Override public ChannelPromise unvoid() { return isVoid() ? new DelegatingChannelPromiseNotifier(delegate.unvoid()) : this; }
@Override public void write(ChannelHandlerContext ctx, Object msg, ChannelPromise promise) throws Exception { if (allIdleTimeNanos > 0) { ChannelPromise unvoidPromise = promise.unvoid(); unvoidPromise.addListener(writeListener); ctx.write(msg, unvoidPromise); } else { ctx.write(msg, promise); } }
@Override public ChannelPromise unvoid() { return isVoid() ? new DelegatingChannelPromiseNotifier(delegate.unvoid()) : this; }
@Override public ChannelFuture goAway(ChannelHandlerContext ctx, int lastStreamId, long errorCode, ByteBuf debugData, ChannelPromise promise) { if (!ctx.channel().isActive()) { // There's no point of sending a GOAWAY frame because the connection is over already. promise.unvoid().trySuccess(); debugData.release(); return promise; } return super.goAway(ctx, lastStreamId, errorCode, debugData, promise); }
@Override public ChannelPromise unvoid() { return isVoid() ? new DelegatingChannelPromiseNotifier(delegate.unvoid()) : this; }
@Override public void close(ChannelHandlerContext ctx, ChannelPromise promise) throws Exception { promise = promise.unvoid(); // Avoid NotYetConnectedException if (!ctx.channel().isActive()) { ctx.close(promise); return; } // If the user has already sent a GO_AWAY frame they may be attempting to do a graceful shutdown which requires // sending multiple GO_AWAY frames. We should only send a GO_AWAY here if one has not already been sent. If // a GO_AWAY has been sent we send a empty buffer just so we can wait to close until all other data has been // flushed to the OS. // https://github.com/netty/netty/issues/5307 final ChannelFuture future = connection().goAwaySent() ? ctx.write(EMPTY_BUFFER) : goAway(ctx, null); ctx.flush(); doGracefulShutdown(ctx, future, promise); }
@Override public ChannelFuture resetStream(final ChannelHandlerContext ctx, int streamId, long errorCode, ChannelPromise promise) { final Http2Stream stream = connection().stream(streamId); if (stream == null) { return resetUnknownStream(ctx, streamId, errorCode, promise.unvoid()); } return resetStream(ctx, stream, errorCode, promise); }
@Override public ChannelFuture goAway(final ChannelHandlerContext ctx, final int lastStreamId, final long errorCode, final ByteBuf debugData, ChannelPromise promise) { promise = promise.unvoid(); final Http2Connection connection = connection(); try {
@Override public void write(ChannelHandlerContext ctx, Object msg, ChannelPromise promise) throws Exception { // modify message on way out to add headers if needed if (msg instanceof HttpResponse) { final HttpResponse response = (HttpResponse) msg; trackResponse(response); // Assume the response writer knows if they can persist or not and sets isKeepAlive on the response if (!isKeepAlive(response) || !isSelfDefinedMessageLength(response)) { // No longer keep alive as the client can't tell when the message is done unless we close connection pendingResponses = 0; persistentConnection = false; } // Server might think it can keep connection alive, but we should fix response header if we know better if (!shouldKeepAlive()) { setKeepAlive(response, false); } } if (msg instanceof LastHttpContent && !shouldKeepAlive()) { promise = promise.unvoid().addListener(ChannelFutureListener.CLOSE); } super.write(ctx, msg, promise); }
private ChannelFuture resetStream(final ChannelHandlerContext ctx, final Http2Stream stream, long errorCode, ChannelPromise promise) { promise = promise.unvoid(); if (stream.isResetSent()) {
promise = promise.unvoid().addListener(closeStreamLocalListener);
@Override public void write(ChannelHandlerContext ctx, Object msg, ChannelPromise promise) throws Exception { // Allow writing with void promise if handler is only configured for read timeout events. if (writerIdleTimeNanos > 0 || allIdleTimeNanos > 0) { ctx.write(msg, promise.unvoid()).addListener(writeListener); } else { ctx.write(msg, promise); } }
@Override public void write(ChannelHandlerContext ctx, Object msg, ChannelPromise promise) throws Exception { if (timeoutNanos > 0) { promise = promise.unvoid(); scheduleTimeout(ctx, promise); } ctx.write(msg, promise); }
@Override public void write(ChannelHandlerContext ctx, Object msg, ChannelPromise promise) throws Exception { if (logger.isEnabled(internalLevel)) { logger.log(internalLevel, format(ctx, "WRITE", msg)); } ChannelPromise unvoid = promise.unvoid(); unvoid.addListener(exceptionListener); ctx.write(msg, promise); } }
@Override public void write(ChannelHandlerContext ctx, Object msg, ChannelPromise promise) throws Exception { if (timeoutNanos > 0) { promise = promise.unvoid(); scheduleTimeout(ctx, promise); } ctx.write(msg, promise); }
@Override public ChannelFuture resetStream(final ChannelHandlerContext ctx, int streamId, long errorCode, ChannelPromise promise) { final Http2Stream stream = connection().stream(streamId); if (stream == null) { return resetUnknownStream(ctx, streamId, errorCode, promise.unvoid()); } return resetStream(ctx, stream, errorCode, promise); }