logger.debug("sent {} bytes to wire", bytesWritten);
if (!toSend.hasRemaining()) {
logger.debug("sent all data in toSend buffer");
closeOrRegisterForRead(key); // should probably only be done if the HttpResponse is finished
} else {
toSend.compact(); // make room for more data be "read" in
}
} catch (IOException e) {
logger.error("Failed to send data to client: {}", e.getMessage());
Closeables.closeQuietly(channel);
}