@Override public ByteBuf writeByte(int value) { buf.writeByte(value); return this; }
@Override public void encodeAsByteBuf(ByteBuf byteBuf) { byteBuf.writeByte(SUBNEGOTIATION_VERSION.byteValue()); byteBuf.writeByte(username.length()); byteBuf.writeBytes(username.getBytes(CharsetUtil.US_ASCII)); byteBuf.writeByte(password.length()); byteBuf.writeBytes(password.getBytes(CharsetUtil.US_ASCII)); } }
@Override public void encodeAsByteBuf(ByteBuf byteBuf) { byteBuf.writeByte(SUBNEGOTIATION_VERSION.byteValue()); byteBuf.writeByte(username.length()); byteBuf.writeBytes(username.getBytes(CharsetUtil.US_ASCII)); byteBuf.writeByte(password.length()); byteBuf.writeBytes(password.getBytes(CharsetUtil.US_ASCII)); } }
@Override public ByteBuf writeByte(int value) { buf.writeByte(value); return this; }
private static void writeUnencodedChunk(ByteBuf in, ByteBuf out, int dataLength) { out.writeByte(1); writeChunkLength(out, dataLength + 4); calculateAndWriteChecksum(in, out); out.writeBytes(in, dataLength); }
private static void encodeCopyWithOffset(ByteBuf out, int offset, int length) { if (length < 12 && offset < 2048) { out.writeByte(COPY_1_BYTE_OFFSET | length - 4 << 2 | offset >> 8 << 5); out.writeByte(offset & 0x0ff); } else { out.writeByte(COPY_2_BYTE_OFFSET | length - 1 << 2); out.writeByte(offset & 0x0ff); out.writeByte(offset >> 8 & 0x0ff); } }
private static void writeUnencodedChunk(ByteBuf in, ByteBuf out, int dataLength) { out.writeByte(1); writeChunkLength(out, dataLength + 4); calculateAndWriteChecksum(in, out); out.writeBytes(in, dataLength); }
private static void encodeCopyWithOffset(ByteBuf out, int offset, int length) { if (length < 12 && offset < 2048) { out.writeByte(COPY_1_BYTE_OFFSET | length - 4 << 2 | offset >> 8 << 5); out.writeByte(offset & 0x0ff); } else { out.writeByte(COPY_2_BYTE_OFFSET | length - 1 << 2); out.writeByte(offset & 0x0ff); out.writeByte(offset >> 8 & 0x0ff); } }
void encode(ByteBuf buf) { if (bytes == null) { HttpHeaders.encodeAscii0(String.valueOf(code()), buf); buf.writeByte(SP); HttpHeaders.encodeAscii0(String.valueOf(reasonPhrase()), buf); } else { buf.writeBytes(bytes); } } }
@Override protected void encodeInitialLine(ByteBuf buf, HttpResponse response) throws Exception { response.getProtocolVersion().encode(buf); buf.writeByte(SP); response.getStatus().encode(buf); buf.writeBytes(CRLF); }
static void encodeAscii0(CharSequence seq, ByteBuf buf) { int length = seq.length(); for (int i = 0 ; i < length; i++) { buf.writeByte(c2b(seq.charAt(i))); } }
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; }
private void writeControlFrameHeader(ByteBuf buffer, int type, byte flags, int length) { buffer.writeShort(version | 0x8000); buffer.writeShort(type); buffer.writeByte(flags); buffer.writeMedium(length); }
@Override protected void encodeHeader(ByteBuf buf, BinaryMemcacheResponse msg) { buf.writeByte(msg.getMagic()); buf.writeByte(msg.getOpcode()); buf.writeShort(msg.getKeyLength()); buf.writeByte(msg.getExtrasLength()); buf.writeByte(msg.getDataType()); buf.writeShort(msg.getStatus()); buf.writeInt(msg.getTotalBodyLength()); buf.writeInt(msg.getOpaque()); buf.writeLong(msg.getCAS()); }
@Override protected void encodeHeader(ByteBuf buf, BinaryMemcacheRequest msg) { buf.writeByte(msg.getMagic()); buf.writeByte(msg.getOpcode()); buf.writeShort(msg.getKeyLength()); buf.writeByte(msg.getExtrasLength()); buf.writeByte(msg.getDataType()); buf.writeShort(msg.getReserved()); buf.writeInt(msg.getTotalBodyLength()); buf.writeInt(msg.getOpaque()); buf.writeLong(msg.getCAS()); }
@Override protected void encodeHeader(ByteBuf buf, BinaryMemcacheRequest msg) { buf.writeByte(msg.getMagic()); buf.writeByte(msg.getOpcode()); buf.writeShort(msg.getKeyLength()); buf.writeByte(msg.getExtrasLength()); buf.writeByte(msg.getDataType()); buf.writeShort(msg.getReserved()); buf.writeInt(msg.getTotalBodyLength()); buf.writeInt(msg.getOpaque()); buf.writeLong(msg.getCAS()); }