View Javadoc

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 HttpHeaders trailingHeaders() {
49              return HttpHeaders.EMPTY_HEADERS;
50          }
51  
52          @Override
53          public DecoderResult getDecoderResult() {
54              return DecoderResult.SUCCESS;
55          }
56  
57          @Override
58          public void setDecoderResult(DecoderResult result) {
59              throw new UnsupportedOperationException("read only");
60          }
61  
62          @Override
63          public int refCnt() {
64              return 1;
65          }
66  
67          @Override
68          public LastHttpContent retain() {
69              return this;
70          }
71  
72          @Override
73          public LastHttpContent retain(int increment) {
74              return this;
75          }
76  
77          @Override
78          public boolean release() {
79              return false;
80          }
81  
82          @Override
83          public boolean release(int decrement) {
84              return false;
85          }
86  
87          @Override
88          public String toString() {
89              return "EmptyLastHttpContent";
90          }
91      };
92  
93      HttpHeaders trailingHeaders();
94  
95      @Override
96      LastHttpContent copy();
97  
98      @Override
99      LastHttpContent retain(int increment);
100 
101     @Override
102     LastHttpContent retain();
103 }