1 /*
2  * Copyright 2012 The Netty Project
3  *
4  * The Netty Project licenses this file to you under the Apache License,
5  * version 2.0 (the "License"); you may not use this file except in compliance
6  * with the License. You may obtain a copy of the License at:
7  *
8  *   http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12  * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13  * License for the specific language governing permissions and limitations
14  * under the License.
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  * The last {@link HttpContent} which has trailing headers.
24  */

25 public interface LastHttpContent extends HttpContent {
26
27     /**
28      * The 'end of content' marker in chunked encoding.
29      */

30     LastHttpContent EMPTY_LAST_CONTENT = new LastHttpContent() {
31
32         @Override
33         public ByteBuf content() {
34             return Unpooled.EMPTY_BUFFER;
35         }
36
37         @Override
38         public LastHttpContent copy() {
39             return EMPTY_LAST_CONTENT;
40         }
41
42         @Override
43         public LastHttpContent duplicate() {
44             return this;
45         }
46
47         @Override
48         public LastHttpContent replace(ByteBuf content) {
49             return new DefaultLastHttpContent(content);
50         }
51
52         @Override
53         public LastHttpContent retainedDuplicate() {
54             return this;
55         }
56
57         @Override
58         public HttpHeaders trailingHeaders() {
59             return EmptyHttpHeaders.INSTANCE;
60         }
61
62         @Override
63         public DecoderResult decoderResult() {
64             return DecoderResult.SUCCESS;
65         }
66
67         @Override
68         @Deprecated
69         public DecoderResult getDecoderResult() {
70             return decoderResult();
71         }
72
73         @Override
74         public void setDecoderResult(DecoderResult result) {
75             throw new UnsupportedOperationException("read only");
76         }
77
78         @Override
79         public int refCnt() {
80             return 1;
81         }
82
83         @Override
84         public LastHttpContent retain() {
85             return this;
86         }
87
88         @Override
89         public LastHttpContent retain(int increment) {
90             return this;
91         }
92
93         @Override
94         public LastHttpContent touch() {
95             return this;
96         }
97
98         @Override
99         public LastHttpContent touch(Object hint) {
100             return this;
101         }
102
103         @Override
104         public boolean release() {
105             return false;
106         }
107
108         @Override
109         public boolean release(int decrement) {
110             return false;
111         }
112
113         @Override
114         public String toString() {
115             return "EmptyLastHttpContent";
116         }
117     };
118
119     HttpHeaders trailingHeaders();
120
121     @Override
122     LastHttpContent copy();
123
124     @Override
125     LastHttpContent duplicate();
126
127     @Override
128     LastHttpContent retainedDuplicate();
129
130     @Override
131     LastHttpContent replace(ByteBuf content);
132
133     @Override
134     LastHttpContent retain(int increment);
135
136     @Override
137     LastHttpContent retain();
138
139     @Override
140     LastHttpContent touch();
141
142     @Override
143     LastHttpContent touch(Object hint);
144 }
145