@Test public void multipleHeadersSameValue() throws Exception { final Header header = BatchParserCommon.consumeHeaders(toLineList( "Content-Id: 1" + CRLF, "Content-Id: 1" + CRLF, "content-type: Application/http" + CRLF, "content-transfer-encoding: Binary" + CRLF)); assertNotNull(header); final List<String> contentIdHeaders = header.getHeaders(HttpHeader.CONTENT_ID); assertNotNull(contentIdHeaders); assertEquals(1, contentIdHeaders.size()); assertEquals("1", contentIdHeaders.get(0)); }
public static Header consumeHeaders(final List<Line> remainingMessage) { final int headerLineNumber = !remainingMessage.isEmpty() ? remainingMessage.get(0).getLineNumber() : 0; final Header headers = new Header(headerLineNumber); final Iterator<Line> iter = remainingMessage.iterator(); Line currentLine; boolean isHeader = true; while (iter.hasNext() && isHeader) { currentLine = iter.next(); final Matcher headerMatcher = PATTERN_HEADER_LINE.matcher(currentLine.toString()); if (headerMatcher.matches() && headerMatcher.groupCount() == 2) { iter.remove(); String headerName = headerMatcher.group(1).trim(); String headerValue = headerMatcher.group(2).trim(); headers.addHeader(headerName, Header.splitValuesByComma(headerValue), currentLine.getLineNumber()); } else { isHeader = false; } } return headers; }
BatchParserCommon { public static Header consumeHeaders(final List<Line> remainingMessage) { final int headerLineNumber = !remainingMessage.isEmpty() ? remainingMessage.get(0).getLineNumber() : 0; final Header headers = new Header(headerLineNumber); final Iterator<Line> iter = remainingMessage.iterator(); Line currentLine; boolean isHeader = true; while (iter.hasNext() && isHeader) { currentLine = iter.next(); final Matcher headerMatcher = PATTERN_HEADER_LINE.matcher(currentLine.toString()); if (headerMatcher.matches() && headerMatcher.groupCount() == 2) { iter.remove(); String headerName = headerMatcher.group(1).trim(); String headerValue = headerMatcher.group(2).trim(); headers.addHeader(headerName, Header.splitValuesByComma(headerValue), currentLine.getLineNumber()); } else { isHeader = false; } } return headers; } }
BatchParserCommon { public static Header consumeHeaders(final List<Line> remainingMessage) { final int headerLineNumber = !remainingMessage.isEmpty() ? remainingMessage.get(0).getLineNumber() : 0; final Header headers = new Header(headerLineNumber); final Iterator<Line> iter = remainingMessage.iterator(); Line currentLine; boolean isHeader = true; while (iter.hasNext() && isHeader) { currentLine = iter.next(); final Matcher headerMatcher = PATTERN_HEADER_LINE.matcher(currentLine.toString()); if (headerMatcher.matches() && headerMatcher.groupCount() == 2) { iter.remove(); String headerName = headerMatcher.group(1).trim(); String headerValue = headerMatcher.group(2).trim(); headers.addHeader(headerName, Header.splitValuesByComma(headerValue), currentLine.getLineNumber()); } else { isHeader = false; } } return headers; } private  BatchParserCommon(); }
BatchParserCommon { public static Header consumeHeaders(final List<Line> remainingMessage) { final int headerLineNumber = !remainingMessage.isEmpty() ? remainingMessage.get(0).getLineNumber() : 0; final Header headers = new Header(headerLineNumber); final Iterator<Line> iter = remainingMessage.iterator(); Line currentLine; boolean isHeader = true; while (iter.hasNext() && isHeader) { currentLine = iter.next(); final Matcher headerMatcher = PATTERN_HEADER_LINE.matcher(currentLine.toString()); if (headerMatcher.matches() && headerMatcher.groupCount() == 2) { iter.remove(); String headerName = headerMatcher.group(1).trim(); String headerValue = headerMatcher.group(2).trim(); headers.addHeader(headerName, Header.splitValuesByComma(headerValue), currentLine.getLineNumber()); } else { isHeader = false; } } return headers; } private  BatchParserCommon(); static String getBoundary(final String contentType, final int line); static ContentType parseContentType(final String contentType, final ContentType expected, final int line); static List<List<Line>> splitMessageByBoundary(final List<Line> message, final String boundary); static Line removeEndingCRLF(final Line line); static Header consumeHeaders(final List<Line> remainingMessage); static void consumeBlankLine(final List<Line> remainingMessage, final boolean isStrict); static InputStream convertLineListToInputStream(final List<Line> messageList, final Charset charset); static String trimLineListToLength(final List<Line> list, final int length); static InputStream convertLineListToInputStream(final List<Line> list, final Charset charset,
      final int length); }
BatchParserCommon { public static Header consumeHeaders(final List<Line> remainingMessage) { final int headerLineNumber = !remainingMessage.isEmpty() ? remainingMessage.get(0).getLineNumber() : 0; final Header headers = new Header(headerLineNumber); final Iterator<Line> iter = remainingMessage.iterator(); Line currentLine; boolean isHeader = true; while (iter.hasNext() && isHeader) { currentLine = iter.next(); final Matcher headerMatcher = PATTERN_HEADER_LINE.matcher(currentLine.toString()); if (headerMatcher.matches() && headerMatcher.groupCount() == 2) { iter.remove(); String headerName = headerMatcher.group(1).trim(); String headerValue = headerMatcher.group(2).trim(); headers.addHeader(headerName, Header.splitValuesByComma(headerValue), currentLine.getLineNumber()); } else { isHeader = false; } } return headers; } private  BatchParserCommon(); static String getBoundary(final String contentType, final int line); static ContentType parseContentType(final String contentType, final ContentType expected, final int line); static List<List<Line>> splitMessageByBoundary(final List<Line> message, final String boundary); static Line removeEndingCRLF(final Line line); static Header consumeHeaders(final List<Line> remainingMessage); static void consumeBlankLine(final List<Line> remainingMessage, final boolean isStrict); static InputStream convertLineListToInputStream(final List<Line> messageList, final Charset charset); static String trimLineListToLength(final List<Line> list, final int length); static InputStream convertLineListToInputStream(final List<Line> list, final Charset charset,
      final int length); static final String CONTENT_TRANSFER_ENCODING; static final String BINARY_ENCODING; }