View Javadoc
1   /*
2    * Copyright 2014 The Netty Project
3    *
4    * The Netty Project licenses this file to you under the Apache License, version 2.0 (the
5    * "License"); you may not use this file except in compliance with the License. You may obtain a
6    * 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 distributed under the License
11   * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
12   * or implied. See the License for the specific language governing permissions and limitations under
13   * the License.
14   */
15  package io.netty5.handler.codec.http2;
16  
17  import io.netty5.buffer.api.Buffer;
18  import io.netty5.util.internal.UnstableApi;
19  
20  /**
21   * Decodes HPACK-encoded headers blocks into {@link Http2Headers}.
22   */
23  @UnstableApi
24  public interface Http2HeadersDecoder {
25      /**
26       * Configuration related elements for the {@link Http2HeadersDecoder} interface
27       */
28      interface Configuration {
29          /**
30           * Represents the value for
31           * <a href="https://tools.ietf.org/html/rfc7540#section-6.5.2">SETTINGS_HEADER_TABLE_SIZE</a>.
32           * This method should only be called by Netty (not users) as a result of a receiving a {@code SETTINGS} frame.
33           */
34          void maxHeaderTableSize(long max) throws Http2Exception;
35  
36          /**
37           * Represents the value for
38           * <a href="https://tools.ietf.org/html/rfc7540#section-6.5.2">SETTINGS_HEADER_TABLE_SIZE</a>. The initial value
39           * returned by this method must be {@link Http2CodecUtil#DEFAULT_HEADER_TABLE_SIZE}.
40           */
41          long maxHeaderTableSize();
42  
43          /**
44           * Configure the maximum allowed size in bytes of each set of headers.
45           * <p>
46           * This method should only be called by Netty (not users) as a result of a receiving a {@code SETTINGS} frame.
47           * @param max <a href="https://tools.ietf.org/html/rfc7540#section-6.5.2">SETTINGS_MAX_HEADER_LIST_SIZE</a>.
48           *      If this limit is exceeded the implementation should attempt to keep the HPACK header tables up to date
49           *      by processing data from the peer, but a {@code RST_STREAM} frame will be sent for the offending stream.
50           * @param goAwayMax Must be {@code >= max}. A {@code GO_AWAY} frame will be generated if this limit is exceeded
51           *                  for any particular stream.
52           * @throws Http2Exception if limits exceed the RFC's boundaries or {@code max > goAwayMax}.
53           */
54          void maxHeaderListSize(long max, long goAwayMax) throws Http2Exception;
55  
56          /**
57           * Represents the value for
58           * <a href="https://tools.ietf.org/html/rfc7540#section-6.5.2">SETTINGS_MAX_HEADER_LIST_SIZE</a>.
59           */
60          long maxHeaderListSize();
61  
62          /**
63           * Represents the upper bound in bytes for a set of headers before a {@code GO_AWAY} should be sent.
64           * This will be {@code <=}
65           * <a href="https://tools.ietf.org/html/rfc7540#section-6.5.2">SETTINGS_MAX_HEADER_LIST_SIZE</a>.
66           */
67          long maxHeaderListSizeGoAway();
68      }
69  
70      /**
71       * Decodes the given headers block and returns the headers.
72       */
73      Http2Headers decodeHeaders(int streamId, Buffer headerBlock) throws Http2Exception;
74  
75      /**
76       * Get the {@link Configuration} for this {@link Http2HeadersDecoder}
77       */
78      Configuration configuration();
79  }