use of io.netty.handler.codec.http.LastHttpContent in project netty by netty.
the class Http2StreamFrameToHttpObjectCodecTest method testUpgradeEmptyEnd.
@Test
public void testUpgradeEmptyEnd() throws Exception {
EmbeddedChannel ch = new EmbeddedChannel(new Http2StreamFrameToHttpObjectCodec(true));
LastHttpContent end = LastHttpContent.EMPTY_LAST_CONTENT;
assertTrue(ch.writeOutbound(end));
Http2DataFrame emptyFrame = ch.readOutbound();
try {
assertThat(emptyFrame.content().readableBytes(), is(0));
assertTrue(emptyFrame.isEndStream());
} finally {
emptyFrame.release();
}
assertThat(ch.readOutbound(), is(nullValue()));
assertFalse(ch.finish());
}
use of io.netty.handler.codec.http.LastHttpContent in project netty by netty.
the class Http2StreamFrameToHttpObjectCodecTest method testDowngradeTrailers.
@Test
public void testDowngradeTrailers() throws Exception {
EmbeddedChannel ch = new EmbeddedChannel(new Http2StreamFrameToHttpObjectCodec(true));
Http2Headers headers = new DefaultHttp2Headers();
headers.set("key", "value");
assertTrue(ch.writeInbound(new DefaultHttp2HeadersFrame(headers, true)));
LastHttpContent trailers = ch.readInbound();
try {
assertThat(trailers.content().readableBytes(), is(0));
assertThat(trailers.trailingHeaders().get("key"), is("value"));
assertFalse(trailers instanceof FullHttpRequest);
} finally {
trailers.release();
}
assertThat(ch.readInbound(), is(nullValue()));
assertFalse(ch.finish());
}
use of io.netty.handler.codec.http.LastHttpContent in project netty by netty.
the class Http2StreamFrameToHttpObjectCodecTest method testDecodeResponseTrailersAsClient.
@Test
public void testDecodeResponseTrailersAsClient() throws Exception {
EmbeddedChannel ch = new EmbeddedChannel(new Http2StreamFrameToHttpObjectCodec(false));
Http2Headers headers = new DefaultHttp2Headers();
headers.set("key", "value");
assertTrue(ch.writeInbound(new DefaultHttp2HeadersFrame(headers, true)));
LastHttpContent trailers = ch.readInbound();
try {
assertThat(trailers.content().readableBytes(), is(0));
assertThat(trailers.trailingHeaders().get("key"), is("value"));
assertFalse(trailers instanceof FullHttpRequest);
} finally {
trailers.release();
}
assertThat(ch.readInbound(), is(nullValue()));
assertFalse(ch.finish());
}
use of io.netty.handler.codec.http.LastHttpContent in project netty by netty.
the class Http2StreamFrameToHttpObjectCodecTest method testDecodeDataAsClient.
@Test
public void testDecodeDataAsClient() throws Exception {
EmbeddedChannel ch = new EmbeddedChannel(new Http2StreamFrameToHttpObjectCodec(false));
ByteBuf hello = Unpooled.copiedBuffer("hello world", CharsetUtil.UTF_8);
assertTrue(ch.writeInbound(new DefaultHttp2DataFrame(hello)));
HttpContent content = ch.readInbound();
try {
assertThat(content.content().toString(CharsetUtil.UTF_8), is("hello world"));
assertFalse(content instanceof LastHttpContent);
} finally {
content.release();
}
assertThat(ch.readInbound(), is(nullValue()));
assertFalse(ch.finish());
}
use of io.netty.handler.codec.http.LastHttpContent in project netty by netty.
the class Http2StreamFrameToHttpObjectCodecTest method testEncodeEmptyEndAsClient.
@Test
public void testEncodeEmptyEndAsClient() throws Exception {
EmbeddedChannel ch = new EmbeddedChannel(new Http2StreamFrameToHttpObjectCodec(false));
LastHttpContent end = LastHttpContent.EMPTY_LAST_CONTENT;
assertTrue(ch.writeOutbound(end));
Http2DataFrame emptyFrame = ch.readOutbound();
try {
assertThat(emptyFrame.content().readableBytes(), is(0));
assertTrue(emptyFrame.isEndStream());
} finally {
emptyFrame.release();
}
assertThat(ch.readOutbound(), is(nullValue()));
assertFalse(ch.finish());
}
Aggregations