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; }
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"); } }