@Test public void shouldSerialiseBodyToByteBufWithJsonContentType() { Body body = new StringBody("şarəs"); ByteBuf result = new BodyDecoderEncoder().bodyToByteBuf(body, MediaType.APPLICATION_JSON_UTF_8.toString()); byte[] bodyBytes = new byte[result.readableBytes()]; result.readBytes(bodyBytes); assertThat(bodyBytes, is(not("şarəs".getBytes(DEFAULT_HTTP_CHARACTER_SET)))); assertThat(bodyBytes, is("şarəs".getBytes(UTF_8))); }
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);  }