} else if (res == -1 && !buffer.hasRemaining()) {
channel.suspendReads();
IoUtils.safeClose(AjpClientConnection.this);
try {
final StreamSinkChannel requestChannel = connection.getSinkChannel();
requestChannel.shutdownWrites();
// will return false if there's a response queued ahead of this one, so we'll set up a listener then
if (!requestChannel.flush()) {
requestChannel.getWriteSetter().set(ChannelListeners.flushingChannelListener(null, null));
requestChannel.resumeWrites();
}