code: public int read( byte b[], int off, int len ) throws IOException {
      int result, left = totalExpected - totalRead;
      if (left <= 0) {
        return -1;
      } else {
        result = in.read(b, off, Math.min(left, len));
      }
      if (result > 0) {
        totalRead += result;
      }
      return result;    
    }
docs: Implement length limitation on top of the <code>read</code> method of
  the wrapped <code>ServletInputStream</code>.
  
  @param      b     destination buffer.
  @param      off   offset at which to start storing bytes.
  @param      len   maximum number of bytes to read.
  @return     the number of bytes read, or <code>-1</code> if the end of
  the stream has been reached.
  @exception  IOException  if an I/O error occurs.