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