Skip to content
Permalink
Browse files
feat: use netty's own unpacking decoder (#26)
  • Loading branch information
tzssangglass committed Jun 2, 2021
1 parent 21e85cb commit 99cea325562a62d2842ee6df62c8aac9355d7468
Showing 1 changed file with 1 addition and 16 deletions.
@@ -17,26 +17,11 @@

package org.apache.apisix.plugin.runner.codec;

import io.netty.buffer.ByteBuf;
import io.netty.channel.ChannelHandlerContext;
import io.netty.handler.codec.LengthFieldBasedFrameDecoder;

public class DelayedDecoder extends LengthFieldBasedFrameDecoder {

public DelayedDecoder() {
super(16777215, 0, 0);
}

@Override
protected ByteBuf decode(ChannelHandlerContext ctx, ByteBuf in) {
in.readByte();
int length = in.readMedium();
if (in.readableBytes() < length) {
return null;
}
in.readerIndex(0);

int readLength = in.readableBytes();
return in.retainedSlice(0, readLength);
super(16777215, 1, 3, 0, 0);
}
}

0 comments on commit 99cea32

Please sign in to comment.