// We need to keep track of the last known starting index *before* we
// attempt to service the next segment. This is needed in case of
// partial reads so that we can revert back to this point.
int preRequestPosition = inputStream.getBuffer().position();
StreamRequestHandlerState state = handleStreamRequestInternal(selectionKey,
dataInputStream,
dataOutputStream);
if(state == StreamRequestHandlerState.READING) {
// We've read our request and handled one segment, but we aren't