@Override public final ByteOrder order() { return buf.order(); }
public SwappedByteBuf(ByteBuf buf) { if (buf == null) { throw new NullPointerException("buf"); } this.buf = buf; if (buf.order() == ByteOrder.BIG_ENDIAN) { order = ByteOrder.LITTLE_ENDIAN; } else { order = ByteOrder.BIG_ENDIAN; } }
@Override @Deprecated public ByteOrder order() { return unwrap().order(); }
@Override public ByteBuf slice(int index, int length) { return buf.slice(index, length).order(order); }
@Override public ByteBuf copy() { return buf.copy().order(order); }
@Override public ByteBuf retainedSlice() { return buf.retainedSlice().order(order); }
@Override public ByteBuf duplicate() { return buf.duplicate().order(order); }
@Override @Deprecated public ByteOrder order() { return unwrap().order(); }
@SuppressWarnings("deprecation") private static short shortBE(ByteBuf buffer, int offset) { return buffer.order() == ByteOrder.BIG_ENDIAN ? buffer.getShort(offset) : buffer.getShortLE(offset); }
@SuppressWarnings("deprecation") private static int unsignedShortBE(ByteBuf buffer, int offset) { return buffer.order() == ByteOrder.BIG_ENDIAN ? buffer.getUnsignedShort(offset) : buffer.getUnsignedShortLE(offset); }
/** * Writes a big-endian 24-bit medium integer to the buffer. */ @SuppressWarnings("deprecation") public static ByteBuf writeMediumBE(ByteBuf buf, int mediumValue) { return buf.order() == ByteOrder.BIG_ENDIAN? buf.writeMedium(mediumValue) : buf.writeMediumLE(mediumValue); }
@Override public ByteBuf readBytes(int length) { return buf.readBytes(length).order(order()); }
public ByteBuf encodePingFrame(ByteBufAllocator allocator, int id) { byte flags = 0; int length = 4; ByteBuf frame = allocator.ioBuffer(SPDY_HEADER_SIZE + length).order(ByteOrder.BIG_ENDIAN); writeControlFrameHeader(frame, SPDY_PING_FRAME, flags, length); frame.writeInt(id); return frame; }
ByteBuf decode(ByteBuf src, int off, int len, ByteBufAllocator allocator, Base64Dialect dialect) { dest = allocator.buffer(decodedBufferSize(len)).order(src.order()); // Upper limit on size of output decodabet = decodabet(dialect); try { src.forEachByte(off, len, this); return dest.slice(0, outBuffPosn); } catch (Throwable cause) { dest.release(); PlatformDependent.throwException(cause); return null; } }
public ByteBuf encodeRstStreamFrame(ByteBufAllocator allocator, int streamId, int statusCode) { byte flags = 0; int length = 8; ByteBuf frame = allocator.ioBuffer(SPDY_HEADER_SIZE + length).order(ByteOrder.BIG_ENDIAN); writeControlFrameHeader(frame, SPDY_RST_STREAM_FRAME, flags, length); frame.writeInt(streamId); frame.writeInt(statusCode); return frame; }
public ByteBuf encodeGoAwayFrame(ByteBufAllocator allocator, int lastGoodStreamId, int statusCode) { byte flags = 0; int length = 8; ByteBuf frame = allocator.ioBuffer(SPDY_HEADER_SIZE + length).order(ByteOrder.BIG_ENDIAN); writeControlFrameHeader(frame, SPDY_GOAWAY_FRAME, flags, length); frame.writeInt(lastGoodStreamId); frame.writeInt(statusCode); return frame; }
public ByteBuf encodeWindowUpdateFrame(ByteBufAllocator allocator, int streamId, int deltaWindowSize) { byte flags = 0; int length = 8; ByteBuf frame = allocator.ioBuffer(SPDY_HEADER_SIZE + length).order(ByteOrder.BIG_ENDIAN); writeControlFrameHeader(frame, SPDY_WINDOW_UPDATE_FRAME, flags, length); frame.writeInt(streamId); frame.writeInt(deltaWindowSize); return frame; } }
public ByteBuf encodeSynReplyFrame(ByteBufAllocator allocator, int streamId, boolean last, ByteBuf headerBlock) { int headerBlockLength = headerBlock.readableBytes(); byte flags = last ? SPDY_FLAG_FIN : 0; int length = 4 + headerBlockLength; ByteBuf frame = allocator.ioBuffer(SPDY_HEADER_SIZE + length).order(ByteOrder.BIG_ENDIAN); writeControlFrameHeader(frame, SPDY_SYN_REPLY_FRAME, flags, length); frame.writeInt(streamId); frame.writeBytes(headerBlock, headerBlock.readerIndex(), headerBlockLength); return frame; }
public ByteBuf encodeHeadersFrame(ByteBufAllocator allocator, int streamId, boolean last, ByteBuf headerBlock) { int headerBlockLength = headerBlock.readableBytes(); byte flags = last ? SPDY_FLAG_FIN : 0; int length = 4 + headerBlockLength; ByteBuf frame = allocator.ioBuffer(SPDY_HEADER_SIZE + length).order(ByteOrder.BIG_ENDIAN); writeControlFrameHeader(frame, SPDY_HEADERS_FRAME, flags, length); frame.writeInt(streamId); frame.writeBytes(headerBlock, headerBlock.readerIndex(), headerBlockLength); return frame; }
public ByteBuf encodeDataFrame(ByteBufAllocator allocator, int streamId, boolean last, ByteBuf data) { byte flags = last ? SPDY_DATA_FLAG_FIN : 0; int length = data.readableBytes(); ByteBuf frame = allocator.ioBuffer(SPDY_HEADER_SIZE + length).order(ByteOrder.BIG_ENDIAN); frame.writeInt(streamId & 0x7FFFFFFF); frame.writeByte(flags); frame.writeMedium(length); frame.writeBytes(data, data.readerIndex(), length); return frame; }