Package io.netty.handler.codec

Examples of io.netty.handler.codec.DecoderResult


            }
        }
    }

    private static void appendDecoderResult(StringBuilder buf, HttpObject o) {
        DecoderResult result = o.getDecoderResult();
        if (result.isSuccess()) {
            return;
        }

        buf.append(".. WITH DECODER FAILURE: ");
        buf.append(result.cause());
        buf.append("\r\n");
    }
View Full Code Here


            }
        }
    }

    private static void appendDecoderResult(StringBuilder buf, HttpObject o) {
        DecoderResult result = o.getDecoderResult();
        if (result.isSuccess()) {
            return;
        }

        buf.append(".. WITH DECODER FAILURE: ");
        buf.append(result.cause());
        buf.append("\r\n");
    }
View Full Code Here


  }

  private static void appendDecoderResult(StringBuilder buf, HttpObject o) {
    DecoderResult result = o.getDecoderResult();
    if (result.isSuccess()) {
      return;
    }

    //buf.append(".. WITH DECODER FAILURE: ");
    //buf.append(result.cause());
View Full Code Here

            }
        }
    }

    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");
    }
View Full Code Here

  }

  @Override
  protected void channelRead(final C connection, final ContextImpl context, final ChannelHandlerContext chctx, final Object msg) throws Exception {
    if (msg instanceof HttpObject) {
      DecoderResult result = ((HttpObject) msg).getDecoderResult();
      if (result.isFailure()) {
        chctx.pipeline().fireExceptionCaught(result.cause());
        return;
      }
    }
    if (connection != null) {
      context.executeSync(() -> doMessageReceived(connection, chctx, msg));
View Full Code Here

    @Test
    public void testRequestWithBadInitialLine() throws Exception {
        EmbeddedChannel ch = new EmbeddedChannel(new HttpRequestDecoder());
        ch.writeInbound(Unpooled.copiedBuffer("GET / HTTP/1.0 with extra\r\n", CharsetUtil.UTF_8));
        HttpRequest req = ch.readInbound();
        DecoderResult dr = req.decoderResult();
        assertFalse(dr.isSuccess());
        assertTrue(dr.isFailure());
        ensureInboundTrafficDiscarded(ch);
    }
View Full Code Here

        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("Good_Name"));
        assertEquals("/maybe-something", req.uri());
        ensureInboundTrafficDiscarded(ch);
    }
View Full Code Here

    @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);
    }
View Full Code Here

        ch.writeInbound(Unpooled.copiedBuffer("HTTP/1.0 200 Maybe OK\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));
        HttpResponse res = ch.readInbound();
        DecoderResult dr = res.decoderResult();
        assertFalse(dr.isSuccess());
        assertTrue(dr.isFailure());
        assertEquals("Maybe OK", res.status().reasonPhrase());
        assertEquals("Good Value", res.headers().get("Good_Name"));
        ensureInboundTrafficDiscarded(ch);
    }
View Full Code Here

        HttpRequest req = ch.readInbound();
        assertTrue(req.decoderResult().isSuccess());

        LastHttpContent chunk = ch.readInbound();
        DecoderResult dr = chunk.decoderResult();
        assertFalse(dr.isSuccess());
        assertTrue(dr.isFailure());
        ensureInboundTrafficDiscarded(ch);
    }
View Full Code Here

TOP

Related Classes of io.netty.handler.codec.DecoderResult

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.