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
16 package io.netty.handler.codec.http2;
17
18 import io.netty.buffer.ByteBuf;
19
20 /**
21 * Decodes HPACK-encoded headers blocks into {@link Http2Headers}.
22 */
23 public interface Http2HeadersDecoder {
24 /**
25 * Configuration related elements for the {@link Http2HeadersDecoder} interface
26 */
27 interface Configuration {
28 /**
29 * Represents the value for
30 * <a href="https://tools.ietf.org/html/rfc7540#section-6.5.2">SETTINGS_HEADER_TABLE_SIZE</a>.
31 * This method should only be called by Netty (not users) as a result of a receiving a {@code SETTINGS} frame.
32 */
33 void maxHeaderTableSize(long max) throws Http2Exception;
34
35 /**
36 * Represents the value for
37 * <a href="https://tools.ietf.org/html/rfc7540#section-6.5.2">SETTINGS_HEADER_TABLE_SIZE</a>. The initial value
38 * returned by this method must be {@link Http2CodecUtil#DEFAULT_HEADER_TABLE_SIZE}.
39 */
40 long maxHeaderTableSize();
41
42 /**
43 * Configure the maximum allowed size in bytes of each set of headers.
44 * <p>
45 * This method should only be called by Netty (not users) as a result of a receiving a {@code SETTINGS} frame.
46 * @param max <a href="https://tools.ietf.org/html/rfc7540#section-6.5.2">SETTINGS_MAX_HEADER_LIST_SIZE</a>.
47 * If this limit is exceeded the implementation should attempt to keep the HPACK header tables up to date
48 * by processing data from the peer, but a {@code RST_STREAM} frame will be sent for the offending stream.
49 * @param goAwayMax Must be {@code >= max}. A {@code GO_AWAY} frame will be generated if this limit is exceeded
50 * for any particular stream.
51 * @throws Http2Exception if limits exceed the RFC's boundaries or {@code max > goAwayMax}.
52 */
53 void maxHeaderListSize(long max, long goAwayMax) throws Http2Exception;
54
55 /**
56 * Represents the value for
57 * <a href="https://tools.ietf.org/html/rfc7540#section-6.5.2">SETTINGS_MAX_HEADER_LIST_SIZE</a>.
58 */
59 long maxHeaderListSize();
60
61 /**
62 * Represents the upper bound in bytes for a set of headers before a {@code GO_AWAY} should be sent.
63 * This will be {@code <=}
64 * <a href="https://tools.ietf.org/html/rfc7540#section-6.5.2">SETTINGS_MAX_HEADER_LIST_SIZE</a>.
65 */
66 long maxHeaderListSizeGoAway();
67 }
68
69 /**
70 * Decodes the given headers block and returns the headers.
71 */
72 Http2Headers decodeHeaders(int streamId, ByteBuf headerBlock) throws Http2Exception;
73
74 /**
75 * Get the {@link Configuration} for this {@link Http2HeadersDecoder}
76 */
77 Configuration configuration();
78 }