use of io.netty.handler.codec.DecoderResult in project netty by netty.
the class HttpSnoopServerHandler method appendDecoderResult.
private static void appendDecoderResult(StringBuilder buf, HttpObject o) {
DecoderResult result = o.decoderResult();
if (result.isSuccess()) {
return;
}
buf.append(".. WITH DECODER FAILURE: ");
buf.append(result.cause());
buf.append("\r\n");
}
use of io.netty.handler.codec.DecoderResult in project netty by netty.
the class HttpInvalidMessageTest method testResponseWithBadInitialLine.
@Test
public void testResponseWithBadInitialLine() throws Exception {
EmbeddedChannel ch = new EmbeddedChannel(new HttpResponseDecoder());
ch.writeInbound(Unpooled.copiedBuffer("HTTP/1.0 BAD_CODE Bad Server\r\n", CharsetUtil.UTF_8));
HttpResponse res = ch.readInbound();
DecoderResult dr = res.decoderResult();
assertFalse(dr.isSuccess());
assertTrue(dr.isFailure());
ensureInboundTrafficDiscarded(ch);
}
use of io.netty.handler.codec.DecoderResult in project netty by netty.
the class HttpInvalidMessageTest method testRequestWithBadHeader.
@Test
public void testRequestWithBadHeader() throws Exception {
EmbeddedChannel ch = new EmbeddedChannel(new HttpRequestDecoder());
ch.writeInbound(Unpooled.copiedBuffer("GET /maybe-something HTTP/1.0\r\n", CharsetUtil.UTF_8));
ch.writeInbound(Unpooled.copiedBuffer("Good_Name: Good Value\r\n", CharsetUtil.UTF_8));
ch.writeInbound(Unpooled.copiedBuffer("Bad=Name: Bad Value\r\n", CharsetUtil.UTF_8));
ch.writeInbound(Unpooled.copiedBuffer("\r\n", CharsetUtil.UTF_8));
HttpRequest req = ch.readInbound();
DecoderResult dr = req.decoderResult();
assertFalse(dr.isSuccess());
assertTrue(dr.isFailure());
assertEquals("Good Value", req.headers().get(of("Good_Name")));
assertEquals("/maybe-something", req.uri());
ensureInboundTrafficDiscarded(ch);
}
Aggregations