final StreamSinkChannel responseChannel = connection.getChannel().getSinkChannel();
responseChannel.shutdownWrites();
// will return false if there's a response queued ahead of this one, so we'll set up a listener then
if (!responseChannel.flush()) {
responseChannel.getWriteSetter().set(ChannelListeners.flushingChannelListener(null, null));
responseChannel.resumeWrites();
}
} catch (IOException e) {
UndertowLogger.REQUEST_IO_LOGGER.ioException(e);
// fuck it, it's all ruined
IoUtils.safeClose(channel);