View Javadoc
1   /*
2    * Copyright 2013 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  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      @Override
31      public HttpHeaders trailingHeaders() {
32          return trailingHeaders;
33      }
34  
35      @Override
36      public LastHttpContent copy() {
37          LastHttpContent content = new DefaultLastHttpContent(Unpooled.EMPTY_BUFFER);
38          content.trailingHeaders().set(trailingHeaders());
39          return content;
40      }
41  
42      @Override
43      public LastHttpContent retain(int increment) {
44          return this;
45      }
46  
47      @Override
48      public LastHttpContent retain() {
49          return this;
50      }
51  
52      @Override
53      public HttpContent duplicate() {
54          return copy();
55      }
56  
57      @Override
58      public ByteBuf content() {
59          return Unpooled.EMPTY_BUFFER;
60      }
61  
62      @Override
63      public DecoderResult getDecoderResult() {
64          return result;
65      }
66  
67      @Override
68      public void setDecoderResult(DecoderResult result) {
69          this.result = result;
70      }
71  
72      @Override
73      public int refCnt() {
74          return 1;
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  }