@Test public void testHeaderBlankLineInNextChunk() { String boundary = "boundary"; final byte[] chunk1 = ("--" + boundary + "\n" + "Content-Id: part1\n" + "Content-Type: text/plain\r\n").getBytes(); final byte[] chunk2 = ("\n" + "part1\n" + "--" + boundary + "--").getBytes(); List<MimePart> parts = parse(boundary, List.of(chunk1, chunk2)).parts; assertThat(parts.size(), is(equalTo(1))); MimePart part1 = parts.get(0); assertThat(part1.headers.size(), is(equalTo(2))); assertThat(part1.headers.get("Content-Id"), hasItems("part1")); assertThat(part1.headers.get("Content-Type"), hasItems("text/plain")); assertThat(part1.content, is(notNullValue())); assertThat(new String(part1.content), is(equalTo("part1"))); }
private static byte[] getBytes(String str) { char[] chars = str.toCharArray(); int size = chars.length; byte[] bytes = new byte[size]; for (int i = 0; i < size;) { bytes[i] = (byte) chars[i++]; } return bytes; }
MimeParser { private static byte[] getBytes(String str) { char[] chars = str.toCharArray(); int size = chars.length; byte[] bytes = new byte[size]; for (int i = 0; i < size;) { bytes[i] = (byte) chars[i++]; } return bytes; } }
MimeParser { private static byte[] getBytes(String str) { char[] chars = str.toCharArray(); int size = chars.length; byte[] bytes = new byte[size]; for (int i = 0; i < size;) { bytes[i] = (byte) chars[i++]; } return bytes; } MimeParser(String boundary); }
MimeParser { private static byte[] getBytes(String str) { char[] chars = str.toCharArray(); int size = chars.length; byte[] bytes = new byte[size]; for (int i = 0; i < size;) { bytes[i] = (byte) chars[i++]; } return bytes; } MimeParser(String boundary);  }
MimeParser { private static byte[] getBytes(String str) { char[] chars = str.toCharArray(); int size = chars.length; byte[] bytes = new byte[size]; for (int i = 0; i < size;) { bytes[i] = (byte) chars[i++]; } return bytes; } MimeParser(String boundary);   }