Search in sources :

Example 1 with DecoderResult

use of io.netty.handler.codec.DecoderResult in project netty by netty.

the class DefaultSocks5PasswordAuthResponse method toString.

@Override
public String toString() {
    StringBuilder buf = new StringBuilder(StringUtil.simpleClassName(this));
    DecoderResult decoderResult = decoderResult();
    if (!decoderResult.isSuccess()) {
        buf.append("(decoderResult: ");
        buf.append(decoderResult);
        buf.append(", status: ");
    } else {
        buf.append("(status: ");
    }
    buf.append(status());
    buf.append(')');
    return buf.toString();
}
Also used : DecoderResult(io.netty.handler.codec.DecoderResult)

Example 2 with DecoderResult

use of io.netty.handler.codec.DecoderResult in project netty by netty.

the class DefaultSocks5CommandRequest method toString.

@Override
public String toString() {
    StringBuilder buf = new StringBuilder(128);
    buf.append(StringUtil.simpleClassName(this));
    DecoderResult decoderResult = decoderResult();
    if (!decoderResult.isSuccess()) {
        buf.append("(decoderResult: ");
        buf.append(decoderResult);
        buf.append(", type: ");
    } else {
        buf.append("(type: ");
    }
    buf.append(type());
    buf.append(", dstAddrType: ");
    buf.append(dstAddrType());
    buf.append(", dstAddr: ");
    buf.append(dstAddr());
    buf.append(", dstPort: ");
    buf.append(dstPort());
    buf.append(')');
    return buf.toString();
}
Also used : DecoderResult(io.netty.handler.codec.DecoderResult)

Example 3 with DecoderResult

use of io.netty.handler.codec.DecoderResult in project netty by netty.

the class DefaultSocks5InitialRequest method toString.

@Override
public String toString() {
    StringBuilder buf = new StringBuilder(StringUtil.simpleClassName(this));
    DecoderResult decoderResult = decoderResult();
    if (!decoderResult.isSuccess()) {
        buf.append("(decoderResult: ");
        buf.append(decoderResult);
        buf.append(", authMethods: ");
    } else {
        buf.append("(authMethods: ");
    }
    buf.append(authMethods());
    buf.append(')');
    return buf.toString();
}
Also used : DecoderResult(io.netty.handler.codec.DecoderResult)

Example 4 with DecoderResult

use of io.netty.handler.codec.DecoderResult in project netty by netty.

the class HttpInvalidMessageTest method testBadChunk.

@Test
public void testBadChunk() throws Exception {
    EmbeddedChannel ch = new EmbeddedChannel(new HttpRequestDecoder());
    ch.writeInbound(Unpooled.copiedBuffer("GET / HTTP/1.0\r\n", CharsetUtil.UTF_8));
    ch.writeInbound(Unpooled.copiedBuffer("Transfer-Encoding: chunked\r\n\r\n", CharsetUtil.UTF_8));
    ch.writeInbound(Unpooled.copiedBuffer("BAD_LENGTH\r\n", CharsetUtil.UTF_8));
    HttpRequest req = ch.readInbound();
    assertTrue(req.decoderResult().isSuccess());
    LastHttpContent chunk = ch.readInbound();
    DecoderResult dr = chunk.decoderResult();
    assertFalse(dr.isSuccess());
    assertTrue(dr.isFailure());
    ensureInboundTrafficDiscarded(ch);
}
Also used : EmbeddedChannel(io.netty.channel.embedded.EmbeddedChannel) DecoderResult(io.netty.handler.codec.DecoderResult) Test(org.junit.Test)

Example 5 with DecoderResult

use of io.netty.handler.codec.DecoderResult in project netty by netty.

the class HttpInvalidMessageTest method testRequestWithBadInitialLine.

@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);
}
Also used : EmbeddedChannel(io.netty.channel.embedded.EmbeddedChannel) DecoderResult(io.netty.handler.codec.DecoderResult) Test(org.junit.Test)

Aggregations

DecoderResult (io.netty.handler.codec.DecoderResult)18 Test (org.junit.Test)7 EmbeddedChannel (io.netty.channel.embedded.EmbeddedChannel)5 Buffer (io.vertx.core.buffer.Buffer)2 WebSocketFrameInternal (io.vertx.core.http.impl.ws.WebSocketFrameInternal)2 TooLongFrameException (io.netty.handler.codec.TooLongFrameException)1 FullHttpRequest (io.netty.handler.codec.http.FullHttpRequest)1 HttpContent (io.netty.handler.codec.http.HttpContent)1 HttpObject (io.netty.handler.codec.http.HttpObject)1 HttpRequest (io.netty.handler.codec.http.HttpRequest)1 HttpResponse (io.netty.handler.codec.http.HttpResponse)1 HttpVersion (io.netty.handler.codec.http.HttpVersion)1 LastHttpContent (io.netty.handler.codec.http.LastHttpContent)1 WebSocketFrameImpl (io.vertx.core.http.impl.ws.WebSocketFrameImpl)1