@Override public void skipBytes(int length) { buffer.skipBytes(length); }
@Override public void skipBytes(int length) { buffer.skipBytes(length); }
public int skipBytes(int n) throws IOException { int nBytes = Math.min(available(), n); buffer.skipBytes(nBytes); return nBytes; }
protected void close(ChannelBuffer buffer, Channel channel) { buffer.skipBytes(buffer.readableBytes()); channel.close(); }
private int readLengthField(ChannelBuffer buffer) { int length = getSignedInt(buffer, buffer.readerIndex()); buffer.skipBytes(LENGTH_FIELD_SIZE); return length; }
public void skipBytes(int length) { checkReadableBytes(length); buf().skipBytes(length); }
@Override void decode(ChannelBuffer headerBlock, SpdyHeadersFrame frame) throws Exception { if (headerBlock == null) { throw new NullPointerException("headerBlock"); } if (frame == null) { throw new NullPointerException("frame"); } int len = setInput(headerBlock); int numBytes; do { numBytes = decompress(frame); } while (numBytes > 0); // z_stream has an internal 64-bit hold buffer // it is always capable of consuming the entire input if (decompressor.getRemaining() != 0) { // we reached the end of the deflate stream throw INVALID_HEADER_BLOCK; } headerBlock.skipBytes(len); }
@Override protected Object decode( ChannelHandlerContext ctx, Channel channel, ChannelBuffer buffer) throws Exception { if (buffer.readableBytes() < frameLength) { return null; } else { ChannelBuffer frame = extractFrame(buffer, buffer.readerIndex(), frameLength); buffer.skipBytes(frameLength); return frame; } }
/** * * @return the next ChannelBuffer to send as a HttpChunk and modifying currentBuffer * accordingly */ private ChannelBuffer fillChannelBuffer() { int length = currentBuffer.readableBytes(); if (length > HttpPostBodyUtil.chunkSize) { ChannelBuffer slice = currentBuffer.slice(currentBuffer.readerIndex(), HttpPostBodyUtil.chunkSize); currentBuffer.skipBytes(HttpPostBodyUtil.chunkSize); return slice; } else { // to continue ChannelBuffer slice = currentBuffer; currentBuffer = null; return slice; } }
@Override protected Object decodeLast(ChannelHandlerContext ctx, Channel channel, ChannelBuffer buffer, VoidEnum state) throws Exception { switch (buffer.readableBytes()) { case 0: return null; case 1: // Ignore the last TC_RESET if (buffer.getByte(buffer.readerIndex()) == ObjectStreamConstants.TC_RESET) { buffer.skipBytes(1); return null; } } Object decoded = decode(ctx, channel, buffer, state); return decoded; }
@Override protected Object decode(ChannelHandlerContext ctx, Channel channel, ChannelBuffer buffer, VoidEnum state) throws Exception { // Discard all data received if closing handshake was received before. if (receivedClosingHandshake) { buffer.skipBytes(actualReadableBytes()); return null; } // Decode a frame otherwise. byte type = buffer.readByte(); if ((type & 0x80) == 0x80) { // If the MSB on type is set, decode the frame length return decodeBinaryFrame(type, buffer); } else { // Decode a 0xff terminated UTF-8 string return decodeTextFrame(buffer); } }
@Override public synchronized ChannelBuffer encode(SpdyHeadersFrame frame) throws Exception { if (frame == null) { throw new IllegalArgumentException("frame"); } if (finished) { return ChannelBuffers.EMPTY_BUFFER; } ChannelBuffer decompressed = super.encode(frame); if (decompressed.readableBytes() == 0) { return ChannelBuffers.EMPTY_BUFFER; } ChannelBuffer compressed = ChannelBuffers.dynamicBuffer(decompressed.readableBytes()); int len = setInput(decompressed); encode(compressed); decompressed.skipBytes(len); return compressed; }
buffer.skipBytes(minFrameLength + minDelimLength); buffer.skipBytes(minFrameLength + minDelimLength); fail(ctx, minFrameLength); return null; frame = extractFrame(buffer, buffer.readerIndex(), minFrameLength + minDelimLength); buffer.skipBytes(minFrameLength + minDelimLength); buffer.skipBytes(buffer.readableBytes()); discardingTooLongFrame = true; if (failFast) { buffer.skipBytes(buffer.readableBytes());
private Object decodeV1(ChannelHandlerContext ctx, Channel channel, ChannelBuffer buffer) throws Exception { buffer.resetReaderIndex(); buffer.skipBytes(2);// skip magic num byte messageType = (byte) buffer.readShort(); long requestId = buffer.readLong(); int dataLength = buffer.readInt(); // FIXME 如果dataLength过大,可能导致问题 if (buffer.readableBytes() < dataLength) { buffer.resetReaderIndex(); return null; } checkMaxContext(dataLength, ctx, channel, messageType == MotanConstants.FLAG_REQUEST, requestId); byte[] data = new byte[dataLength]; buffer.readBytes(data); return decode(data, channel, messageType == MotanConstants.FLAG_REQUEST, requestId); }
buffer.skipBytes(1);
buffer.skipBytes(1); int rpcVersion = (buffer.readByte() & 0xff) >>> 3; Object result;
@Override protected Object decode( ChannelHandlerContext ctx, Channel channel, ChannelBuffer buffer, VoidEnum state) throws Exception { if (discardingTooLongFrame) { buffer.skipBytes(actualReadableBytes()); checkpoint(); return null; } Unmarshaller unmarshaller = provider.getUnmarshaller(ctx); ByteInput input = new ChannelBufferByteInput(buffer); if (maxObjectSize != Integer.MAX_VALUE) { input = new LimitingByteInput(input, maxObjectSize); } try { unmarshaller.start(input); Object obj = unmarshaller.readObject(); unmarshaller.finish(); return obj; } catch (LimitingByteInput.TooBigObjectException e) { discardingTooLongFrame = true; throw new TooLongFrameException(); } finally { // Call close in a finally block as the ReplayingDecoder will throw an Error if not enough bytes are // readable. This helps to be sure that we do not leak resource unmarshaller.close(); } }
buffer.skipBytes(length + delimLength);