Search in sources :

Example 6 with Body

use of org.asynchttpclient.request.body.Body in project async-http-client by AsyncHttpClient.

the class FeedableBodyGeneratorTest method readingBytesReturnsFedContentWithoutChunkBoundaries.

@Test
public void readingBytesReturnsFedContentWithoutChunkBoundaries() throws Exception {
    byte[] content = "Test123".getBytes(StandardCharsets.US_ASCII);
    ByteBuf source = Unpooled.wrappedBuffer(content);
    ByteBuf target = Unpooled.buffer(1);
    try {
        feedableBodyGenerator.feed(source, true);
        Body body = feedableBodyGenerator.createBody();
        assertEquals(readFromBody(body), "Test123".getBytes(StandardCharsets.US_ASCII));
        assertEquals(body.transferTo(target), BodyState.STOP);
    } finally {
        source.release();
        target.release();
    }
}
Also used : ByteBuf(io.netty.buffer.ByteBuf) Body(org.asynchttpclient.request.body.Body) Test(org.testng.annotations.Test)

Aggregations

ByteBuf (io.netty.buffer.ByteBuf)6 Body (org.asynchttpclient.request.body.Body)6 Test (org.testng.annotations.Test)6 ByteArrayBodyGenerator (org.asynchttpclient.request.body.generator.ByteArrayBodyGenerator)2