out.add(in.readRetainedSlice(frameLengthInt));
for (int remaining = dataLen;;) { if (remaining < maxDataLen) { flushBuffer(future, buf.readRetainedSlice(remaining), nextSubPacketOffsetInBlock, syncBlock); break; } else { flushBuffer(new CompletableFuture<>(), buf.readRetainedSlice(maxDataLen), nextSubPacketOffsetInBlock, syncBlock); remaining -= maxDataLen;
private RPCProtos.RequestHeader getHeader(ByteBuf in, int headerSize) throws IOException { ByteBuf msg = in.readRetainedSlice(headerSize); try { byte[] array; int offset; int length = msg.readableBytes(); if (msg.hasArray()) { array = msg.array(); offset = msg.arrayOffset() + msg.readerIndex(); } else { array = new byte[length]; msg.getBytes(msg.readerIndex(), array, 0, length); offset = 0; } RPCProtos.RequestHeader.Builder builder = RPCProtos.RequestHeader.newBuilder(); ProtobufUtil.mergeFrom(builder, array, offset, length); return builder.build(); } finally { msg.release(); } }
@Override public ByteBuf readRetainedSlice(int length) { return buf.readRetainedSlice(length); }
@Override public ByteBuf readRetainedSlice(int length) { return buf.readRetainedSlice(length).order(order); }
@Override public ByteBuf readRetainedSlice(int length) { checkReadableBytes(length); return buffer.readRetainedSlice(length); }
private static Result<ByteBuf> decodePublishPayload(ByteBuf buffer, int bytesRemainingInVariablePart) { ByteBuf b = buffer.readRetainedSlice(bytesRemainingInVariablePart); return new Result<ByteBuf>(b, bytesRemainingInVariablePart); }
/** * * @return the next ByteBuf to send as a HttpChunk and modifying currentBuffer accordingly */ private ByteBuf fillByteBuf() { int length = currentBuffer.readableBytes(); if (length > HttpPostBodyUtil.chunkSize) { return currentBuffer.readRetainedSlice(HttpPostBodyUtil.chunkSize); } else { // to continue ByteBuf slice = currentBuffer; currentBuffer = null; return slice; } }
/** * Create a frame out of the {@link ByteBuf} and return it. * * @param ctx the {@link ChannelHandlerContext} which this {@link ByteToMessageDecoder} belongs to * @param in the {@link ByteBuf} from which to read data * @return frame the {@link ByteBuf} which represent the frame or {@code null} if no frame could * be created. */ protected Object decode( @SuppressWarnings("UnusedParameters") ChannelHandlerContext ctx, ByteBuf in) throws Exception { if (in.readableBytes() < frameLength) { return null; } else { return in.readRetainedSlice(frameLength); } } }
@Override protected void decode(ChannelHandlerContext ctx, ByteBuf in, List<Object> out) throws Exception { in.markReaderIndex(); int preIndex = in.readerIndex(); int length = readRawVarint32(in); if (preIndex == in.readerIndex()) { return; } if (length < 0) { throw new CorruptedFrameException("negative length: " + length); } if (in.readableBytes() < length) { in.resetReaderIndex(); } else { out.add(in.readRetainedSlice(length)); } }
@Override protected void decode(ChannelHandlerContext ctx, ByteBuf in, List<Object> out) throws Exception { try { switch (state()) { case INIT: { final byte version = in.readByte(); if (version != 1) { throw new DecoderException("unsupported subnegotiation version: " + version + " (expected: 1)"); } out.add(new DefaultSocks5PasswordAuthResponse(Socks5PasswordAuthStatus.valueOf(in.readByte()))); checkpoint(State.SUCCESS); } case SUCCESS: { int readableBytes = actualReadableBytes(); if (readableBytes > 0) { out.add(in.readRetainedSlice(readableBytes)); } break; } case FAILURE: { in.skipBytes(actualReadableBytes()); break; } } } catch (Exception e) { fail(out, e); } }
case PP2_TYPE_NETNS: case OTHER: return new HAProxyTLV(type, typeAsByte, header.readRetainedSlice(length)); default: return null;
@Override protected void decode(ChannelHandlerContext ctx, ByteBuf in, List<Object> out) throws Exception { try { switch (state()) { case INIT: { final byte version = in.readByte(); if (version != SocksVersion.SOCKS5.byteValue()) { throw new DecoderException( "unsupported version: " + version + " (expected: " + SocksVersion.SOCKS5.byteValue() + ')'); } final Socks5AuthMethod authMethod = Socks5AuthMethod.valueOf(in.readByte()); out.add(new DefaultSocks5InitialResponse(authMethod)); checkpoint(State.SUCCESS); } case SUCCESS: { int readableBytes = actualReadableBytes(); if (readableBytes > 0) { out.add(in.readRetainedSlice(readableBytes)); } break; } case FAILURE: { in.skipBytes(actualReadableBytes()); break; } } } catch (Exception e) { fail(out, e); } }
int readableBytes = actualReadableBytes(); if (readableBytes > 0) { out.add(in.readRetainedSlice(readableBytes));
int readableBytes = actualReadableBytes(); if (readableBytes > 0) { out.add(in.readRetainedSlice(readableBytes));
int readableBytes = actualReadableBytes(); if (readableBytes > 0) { out.add(in.readRetainedSlice(readableBytes));
int readableBytes = actualReadableBytes(); if (readableBytes > 0) { out.add(in.readRetainedSlice(readableBytes));
int readableBytes = actualReadableBytes(); if (readableBytes > 0) { out.add(in.readRetainedSlice(readableBytes));
int readableBytes = actualReadableBytes(); if (readableBytes > 0) { out.add(in.readRetainedSlice(readableBytes));
ByteBuf fragment = headerBlock.readRetainedSlice(fragmentReadableBytes);