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 readSlice(int length) { return buf.readSlice(length).order(order); }
@Override public ByteBuf slice() { return buf.slice().order(order); }
@Override @Deprecated public ByteOrder order() { return unwrap().order(); }
@Override @Deprecated public ByteOrder order() { return unwrap().order(); }
@Override protected ByteBuf allocateBuffer(ChannelHandlerContext ctx, ByteBuf msg, boolean preferDirect) throws Exception { return super.allocateBuffer(ctx, msg, preferDirect).order(byteOrder); } }
@SuppressWarnings("deprecation") private static int unsignedShortBE(ByteBuf buffer, int offset) { return buffer.order() == ByteOrder.BIG_ENDIAN ? buffer.getUnsignedShort(offset) : ByteBufUtil.swapShort(buffer.getShort(offset)) & 0xFFFF; }
@SuppressWarnings("deprecation") private static short shortBE(ByteBuf buffer, int offset) { return buffer.order() == ByteOrder.BIG_ENDIAN ? buffer.getShort(offset) : ByteBufUtil.swapShort(buffer.getShort(offset)); }
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 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 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 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 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 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; }
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; }