code: protected boolean drainInput(boolean close) throws IOException{
          if(buffer==null)
              buffer = allocator.allocate();
          try{
              while(true){
                  int read;
                  if(in instanceof BufferInput){
                      ((BufferInput)in).drainBuffer();
                      read = -1;
                  }else
                      read = in.read(buffer);
  
                  if(read==0){
                      in.addReadInterest();
                      return false;
                  }else if(read==-1){
                      if(close)
                          in.close();
                      drainDone();
                      return true;
                  }else
                      buffer.clear();
              }
          }catch(Throwable thr){
              drainDone();
              throw thr;
          }
      }
docs: /*-------------------------------------------------[ drainInputs ]---------------------------------------------------