Java Code Examples for io.netty.handler.codec.DecoderResult#SUCCESS

The following examples show how to use io.netty.handler.codec.DecoderResult#SUCCESS . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: RiposteHandlerInternalUtilTest.java    From riposte with Apache License 2.0 6 votes vote down vote up
@DataProvider(value = {
    "true",
    "false"
})
@Test
public void getDecoderFailure_returns_null_when_DecoderResult_is_not_a_failure(
    boolean isUnfinished
) {
    // given
    HttpObject httpObjectMock = mock(HttpObject.class);
    DecoderResult nonFailureDecoderResult = (isUnfinished) ? DecoderResult.UNFINISHED : DecoderResult.SUCCESS;
    doReturn(nonFailureDecoderResult).when(httpObjectMock).decoderResult();

    // when
    Throwable result = implSpy.getDecoderFailure(httpObjectMock);

    // then
    assertThat(result).isNull();
}
 
Example 2
Source File: NettyHttpResponse.java    From spring-boot-protocol with Apache License 2.0 5 votes vote down vote up
@Override
public void recycle() {
    this.content = null;
    this.headers.clear();
    this.version = HttpVersion.HTTP_1_1;
    this.status = DEFAULT_STATUS;
    this.lastHttpContent = null;
    this.decoderResult = DecoderResult.SUCCESS;
}
 
Example 3
Source File: HttpSimpleHandler.java    From shadowsocks-java with MIT License 5 votes vote down vote up
@Override
protected void channelRead0(ChannelHandlerContext ctx, HttpObject msg) throws Exception {
    if (msg.decoderResult() != DecoderResult.SUCCESS) {
        logger.error("simple_http decode error ,pip close");
        ctx.channel().close();
        return;
    }
    if (msg instanceof HttpRequest) {
        logger.debug(((HttpRequest) msg).uri());
        String[] hexItems = ((HttpRequest) msg).uri().split("%");
        StringBuilder hexStr = new StringBuilder();
        if (hexItems.length > 1) {
            for (int i = 1; i < hexItems.length; i++) {
                if (hexItems[i].length() == 2) {
                    hexStr.append(hexItems[i]);
                } else {
                    hexStr.append(hexItems[i], 0, 2);
                    break;
                }
            }
        }
        ByteBuf encodeData = Unpooled.wrappedBuffer(Hex.decode(hexStr.toString()));
        ctx.writeAndFlush(new DefaultFullHttpResponse(HttpVersion.HTTP_1_1, HttpResponseStatus.OK));
        ctx.fireChannelRead(encodeData);
    } else if (msg instanceof HttpContent) {
        ctx.pipeline().remove(HttpServerCodec.class);
        ctx.pipeline().remove(this);
    }
}
 
Example 4
Source File: LastHttpContent.java    From netty-4.1.22 with Apache License 2.0 4 votes vote down vote up
@Override
public DecoderResult decoderResult() {
    return DecoderResult.SUCCESS;
}
 
Example 5
Source File: HttpRequestEncoderTest.java    From netty-4.1.22 with Apache License 2.0 4 votes vote down vote up
@Override
public DecoderResult decoderResult() {
    return DecoderResult.SUCCESS;
}
 
Example 6
Source File: MqttMessage.java    From netty-4.1.22 with Apache License 2.0 4 votes vote down vote up
public MqttMessage(MqttFixedHeader mqttFixedHeader, Object variableHeader, Object payload) {
    this(mqttFixedHeader, variableHeader, payload, DecoderResult.SUCCESS);
}
 
Example 7
Source File: LastStompContentSubframe.java    From netty-4.1.22 with Apache License 2.0 4 votes vote down vote up
@Override
public DecoderResult decoderResult() {
    return DecoderResult.SUCCESS;
}
 
Example 8
Source File: LastMemcacheContent.java    From netty-4.1.22 with Apache License 2.0 4 votes vote down vote up
@Override
public DecoderResult decoderResult() {
    return DecoderResult.SUCCESS;
}
 
Example 9
Source File: NettyHttpResponse.java    From spring-boot-protocol with Apache License 2.0 4 votes vote down vote up
public NettyHttpResponse() {
    this.headers = new DefaultHttpHeaders(false);
    this.version = HttpVersion.HTTP_1_1;
    this.status = DEFAULT_STATUS;
    this.decoderResult = DecoderResult.SUCCESS;
}
 
Example 10
Source File: LastHttpContent.java    From netty4.0.27Learn with Apache License 2.0 4 votes vote down vote up
@Override
public DecoderResult getDecoderResult() {
    return DecoderResult.SUCCESS;
}
 
Example 11
Source File: MqttMessage.java    From mithqtt with Apache License 2.0 4 votes vote down vote up
public MqttMessage(MqttFixedHeader fixedHeader, Object variableHeader, Object payload) {
    this(fixedHeader, variableHeader, payload, DecoderResult.SUCCESS);
}
 
Example 12
Source File: LastMemcacheContent.java    From couchbase-jvm-core with Apache License 2.0 4 votes vote down vote up
@Override
public DecoderResult getDecoderResult() {
    return DecoderResult.SUCCESS;
}