private void readProlog() throws IOException {
   sequenceMatcher.setBytesHandler(NOOP_HANDLER);
   sequenceMatcher.findSequence(-1, HYPHENS, boundaryMarker);
   if (!sequenceMatcher.isMatchedAndNotEOF()) {
     throw new IOException("Request prolog cannot be read");
   }
 }
 private void readData(final Param param) throws IOException {
   sequenceMatcher.setBytesHandler(param);
   sequenceMatcher.findSequence(CHUNK_SIZE, CR_LF, HYPHENS, boundaryMarker);
   if (!this.sequenceMatcher.isMatchedAndNotEOF()) {
     throw new IOException("Request data cannot be read");
   }
 }
  private Param readHeader() throws IOException {
    if (sequenceMatcher.isEOF()) {
      return null;
    }

    if (headersHandler == null) {
      headersHandler = new HeadersHandler();
    } else {
      headersHandler.reset();
    }

    sequenceMatcher.setBytesHandler(headersHandler);
    sequenceMatcher.findSequence(-1, CR_LF);

    if (sequenceMatcher.isMatchedAndNotEOF() && !headersHandler.dataEquals(HYPHENS)) {
      headersHandler.reset();

      sequenceMatcher.findSequence(-1, CR_LF, CR_LF);

      if (!sequenceMatcher.isMatchedAndNotEOF()) {
        throw new IOException("Request header cannot be read");
      }

      String headersString = headersHandler.asString();
      Map<String, String> headers = new HashMap<String, String>();
      String[] split = headersString.split("\r\n");
      for (String headerString : split) {
        parseParams(headerString, "; ", headers);
      }

      return createParam(headers);
    }

    return null;
  }
  public void parseRequest() {
    canStop = true;

    setupProgressData();

    try {
      initialize();

      while (!sequenceMatcher.isEOF()) {
        readNext();
      }
    } catch (IOException e) {
      this.cancel();

      if (!this.shouldStop) {
        throw new FileUploadException("IO Error parsing multipart request", e);
      }
    } finally {
      canStop = false;
    }
  }
  private Param getParam(String name) {
    Param param = null;
    if (parameters != null) {
      param = parameters.get(name);
    }

    if (param == null) {
      if (!canceled) {
        try {
          initialize();

          while (param == null && !sequenceMatcher.isEOF()) {
            readNext();
            param = parameters.get(name);
          }
        } catch (IOException e) {
          this.cancel();
          throw new FileUploadException("IO Error parsing multipart request", e);
        }
      }
    }

    return param;
  }