1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package io.netty.handler.codec.http;
17
18 import io.netty.buffer.ByteBuf;
19 import io.netty.buffer.Unpooled;
20 import io.netty.handler.codec.DecoderResult;
21
22
23 final class ComposedLastHttpContent implements LastHttpContent {
24 private final HttpHeaders trailingHeaders;
25 private DecoderResult result;
26
27 ComposedLastHttpContent(HttpHeaders trailingHeaders) {
28 this.trailingHeaders = trailingHeaders;
29 }
30
31 ComposedLastHttpContent(HttpHeaders trailingHeaders, DecoderResult result) {
32 this(trailingHeaders);
33 this.result = result;
34 }
35
36 @Override
37 public HttpHeaders trailingHeaders() {
38 return trailingHeaders;
39 }
40
41 @Override
42 public LastHttpContent copy() {
43 LastHttpContent content = new DefaultLastHttpContent(Unpooled.EMPTY_BUFFER);
44 content.trailingHeaders().set(trailingHeaders());
45 return content;
46 }
47
48 @Override
49 public LastHttpContent duplicate() {
50 return copy();
51 }
52
53 @Override
54 public LastHttpContent retainedDuplicate() {
55 return copy();
56 }
57
58 @Override
59 public LastHttpContent replace(ByteBuf content) {
60 final LastHttpContent dup = new DefaultLastHttpContent(content);
61 dup.trailingHeaders().setAll(trailingHeaders());
62 return dup;
63 }
64
65 @Override
66 public LastHttpContent retain(int increment) {
67 return this;
68 }
69
70 @Override
71 public LastHttpContent retain() {
72 return this;
73 }
74
75 @Override
76 public LastHttpContent touch() {
77 return this;
78 }
79
80 @Override
81 public LastHttpContent touch(Object hint) {
82 return this;
83 }
84
85 @Override
86 public ByteBuf content() {
87 return Unpooled.EMPTY_BUFFER;
88 }
89
90 @Override
91 public DecoderResult decoderResult() {
92 return result;
93 }
94
95 @Override
96 public DecoderResult getDecoderResult() {
97 return decoderResult();
98 }
99
100 @Override
101 public void setDecoderResult(DecoderResult result) {
102 this.result = result;
103 }
104
105 @Override
106 public int refCnt() {
107 return 1;
108 }
109
110 @Override
111 public boolean release() {
112 return false;
113 }
114
115 @Override
116 public boolean release(int decrement) {
117 return false;
118 }
119 }