@Test public void shouldSerialiseBodyToChunkedByteBufWithNoContentType() { Body body = new StringBody("bytes"); ByteBuf[] result = new BodyDecoderEncoder().bodyToByteBuf(body, null, 2); assertThat(result.length, is(3)); byte[] bodyBytes = new byte[result[0].readableBytes()]; result[0].readBytes(bodyBytes); assertThat(bodyBytes, is("by".getBytes(DEFAULT_HTTP_CHARACTER_SET))); bodyBytes = new byte[result[1].readableBytes()]; result[1].readBytes(bodyBytes); assertThat(bodyBytes, is("te".getBytes(DEFAULT_HTTP_CHARACTER_SET))); bodyBytes = new byte[result[2].readableBytes()]; result[2].readBytes(bodyBytes); assertThat(bodyBytes, is("s".getBytes(DEFAULT_HTTP_CHARACTER_SET))); }
public ByteBuf bodyToByteBuf(Body body, String contentTypeHeader) { byte[] bytes = bodyToBytes(body, contentTypeHeader); if (bytes != null) { return Unpooled.copiedBuffer(bytes); } else { return Unpooled.buffer(0, 0); } }
BodyDecoderEncoder { public ByteBuf bodyToByteBuf(Body body, String contentTypeHeader) { byte[] bytes = bodyToBytes(body, contentTypeHeader); if (bytes != null) { return Unpooled.copiedBuffer(bytes); } else { return Unpooled.buffer(0, 0); } } }
BodyDecoderEncoder { public ByteBuf bodyToByteBuf(Body body, String contentTypeHeader) { byte[] bytes = bodyToBytes(body, contentTypeHeader); if (bytes != null) { return Unpooled.copiedBuffer(bytes); } else { return Unpooled.buffer(0, 0); } }  }
BodyDecoderEncoder { public ByteBuf bodyToByteBuf(Body body, String contentTypeHeader) { byte[] bytes = bodyToBytes(body, contentTypeHeader); if (bytes != null) { return Unpooled.copiedBuffer(bytes); } else { return Unpooled.buffer(0, 0); } }  ByteBuf bodyToByteBuf(Body body, String contentTypeHeader); ByteBuf[] bodyToByteBuf(Body body, String contentTypeHeader, int chunkSize); static byte[][] split(byte[] array, int chunkSize); BodyWithContentType byteBufToBody(ByteBuf content, String contentTypeHeader); }
BodyDecoderEncoder { public ByteBuf bodyToByteBuf(Body body, String contentTypeHeader) { byte[] bytes = bodyToBytes(body, contentTypeHeader); if (bytes != null) { return Unpooled.copiedBuffer(bytes); } else { return Unpooled.buffer(0, 0); } }  ByteBuf bodyToByteBuf(Body body, String contentTypeHeader); ByteBuf[] bodyToByteBuf(Body body, String contentTypeHeader, int chunkSize); static byte[][] split(byte[] array, int chunkSize); BodyWithContentType byteBufToBody(ByteBuf content, String contentTypeHeader);  }