@Override
    public int read(byte[] b, int off, int len) throws IOException {
      int result;
      try {
        result = myDelegate.read(b, off, len);
      }
      catch (IOException e) {
        myStreamCopy = null;
        throw e;
      }
      if (myStreamCopy != null) {
        if (result < 0) {
          cacheResult(myURL, myStreamCopy.toByteArray());
          myStreamCopy = null;
        }
        else if (myStreamCopy.size() + result > MAX_DATA_SIZE) {
          myStreamCopy = null;
        }
        else {
          myStreamCopy.write(b, off, result);
        }
      }
      return result;
    }
@Override
    public int read(byte[] b, int off, int len)