View Javadoc
1   /*
2    * Copyright 2021 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    *   https://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.handler.codec.DecoderResult;
19  
20  /**
21   * A {@link DecoderResult} for {@link HttpMessage}s as produced by an {@link HttpObjectDecoder}.
22   * <p>
23   * Please note that there is no guarantee that a {@link HttpObjectDecoder} will produce a {@link
24   * HttpMessageDecoderResult}. It may simply produce a regular {@link DecoderResult}. This result is intended for
25   * successful {@link HttpMessage} decoder results.
26   */
27  public final class HttpMessageDecoderResult extends DecoderResult {
28  
29      private final int initialLineLength;
30      private final int headerSize;
31  
32      HttpMessageDecoderResult(int initialLineLength, int headerSize) {
33          super(SIGNAL_SUCCESS);
34          this.initialLineLength = initialLineLength;
35          this.headerSize = headerSize;
36      }
37  
38      /**
39       * The decoded initial line length (in bytes), as controlled by {@code maxInitialLineLength}.
40       */
41      public int initialLineLength() {
42          return initialLineLength;
43      }
44  
45      /**
46       * The decoded header size (in bytes), as controlled by {@code maxHeaderSize}.
47       */
48      public int headerSize() {
49          return headerSize;
50      }
51  
52      /**
53       * The decoded initial line length plus the decoded header size (in bytes).
54       */
55      public int totalSize() {
56          return initialLineLength + headerSize;
57      }
58  }