1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package io.netty.handler.codec.memcache.binary;
17
18 import io.netty.buffer.ByteBuf;
19 import io.netty.buffer.Unpooled;
20 import io.netty.util.internal.UnstableApi;
21
22
23
24
25 @UnstableApi
26 public class BinaryMemcacheResponseDecoder
27 extends AbstractBinaryMemcacheDecoder<BinaryMemcacheResponse> {
28
29 public BinaryMemcacheResponseDecoder() {
30 this(DEFAULT_MAX_CHUNK_SIZE);
31 }
32
33 public BinaryMemcacheResponseDecoder(int chunkSize) {
34 super(chunkSize);
35 }
36
37 @Override
38 protected BinaryMemcacheResponse decodeHeader(ByteBuf in) {
39 DefaultBinaryMemcacheResponse header = new DefaultBinaryMemcacheResponse();
40 header.setMagic(in.readByte());
41 header.setOpcode(in.readByte());
42 header.setKeyLength(in.readShort());
43 header.setExtrasLength(in.readByte());
44 header.setDataType(in.readByte());
45 header.setStatus(in.readShort());
46 header.setTotalBodyLength(in.readInt());
47 header.setOpaque(in.readInt());
48 header.setCas(in.readLong());
49 return header;
50 }
51
52 @Override
53 protected BinaryMemcacheResponse buildInvalidMessage() {
54 return new DefaultBinaryMemcacheResponse(Unpooled.EMPTY_BUFFER, Unpooled.EMPTY_BUFFER);
55 }
56 }