@Test public void test() { List<ByteBuf> split = new ArrayList<>(); int i = 0; while (i < DATA.length() / 5 - 1) { split.add(ByteBuf.wrapForReading(DATA.substring(i * 5, ++i * 5).getBytes(UTF_8))); } if (DATA.length() != (i *= 5)) { split.add(ByteBuf.wrapForReading(DATA.substring(i).getBytes(UTF_8))); } List<Map<String, String>> headers = new ArrayList<>(); String res = await(BinaryChannelSupplier.of(ChannelSupplier.ofIterable(split)) .parseStream(MultipartParser.create(BOUNDARY.substring(2))) .toCollector(mapping(frame -> { if (frame.isData()) { return frame.getData().asString(UTF_8); } assertFalse(frame.getHeaders().isEmpty()); headers.add(frame.getHeaders()); return ""; }, joining()))); assertEquals("This is some bytes of data to be extracted from the multipart form\r\n" + "Also here we had a wild CRLF se\r\nquence appear\n" + "And the second line, huh\n", res); assertEquals(asList( map("content-disposition", "form-data; name=\"file\"; filename=\"test.txt\"", "content-type", "text/plain"), map("content-disposition", "form-data; name=\"file\"; filename=\"test.txt\"", "content-type", "text/plain", "test-extra-header", "one", "test-extra-header-2", "two") ), headers); }
public static MultipartParser create(String boundary) { return new MultipartParser(boundary); }
MultipartParser implements ByteBufsDecoder<MultipartFrame> { public static MultipartParser create(String boundary) { return new MultipartParser(boundary); } }
MultipartParser implements ByteBufsDecoder<MultipartFrame> { public static MultipartParser create(String boundary) { return new MultipartParser(boundary); } private  MultipartParser(String boundary); }
MultipartParser implements ByteBufsDecoder<MultipartFrame> { public static MultipartParser create(String boundary) { return new MultipartParser(boundary); } private  MultipartParser(String boundary); static MultipartParser create(String boundary); ByteBufsDecoder<ByteBuf> ignoreHeaders(); Promise<Void> split(ChannelSupplier<ByteBuf> source, MultipartDataHandler dataHandler); @Nullable @Override MultipartFrame tryDecode(ByteBufQueue bufs); }
MultipartParser implements ByteBufsDecoder<MultipartFrame> { public static MultipartParser create(String boundary) { return new MultipartParser(boundary); } private  MultipartParser(String boundary); static MultipartParser create(String boundary); ByteBufsDecoder<ByteBuf> ignoreHeaders(); Promise<Void> split(ChannelSupplier<ByteBuf> source, MultipartDataHandler dataHandler); @Nullable @Override MultipartFrame tryDecode(ByteBufQueue bufs);  }