View Javadoc
1   /*
2    * Copyright 2020 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.http3;
17  
18  import org.jetbrains.annotations.Nullable;
19  
20  import java.util.Map;
21  
22  /**
23   * See <a href="https://tools.ietf.org/html/draft-ietf-quic-http-32#section-7.2.4">SETTINGS</a>.
24   */
25  public interface Http3SettingsFrame extends Http3ControlStreamFrame, Iterable<Map.Entry<Long, Long>> {
26  
27      /**
28       * See <a href="https://tools.ietf.org/html/draft-ietf-quic-qpack-19#section-5">
29       *     SETTINGS_QPACK_MAX_TABLE_CAPACITY</a>.
30       */
31      long HTTP3_SETTINGS_QPACK_MAX_TABLE_CAPACITY = 0x1;
32      /**
33       * See <a href="https://tools.ietf.org/html/draft-ietf-quic-qpack-19#section-5">
34       *     SETTINGS_QPACK_BLOCKED_STREAMS</a>.
35       */
36      long HTTP3_SETTINGS_QPACK_BLOCKED_STREAMS = 0x7;
37      /**
38       * See <a href="https://tools.ietf.org/html/draft-ietf-quic-http-32#section-7.2.4.1">
39       *     SETTINGS_MAX_FIELD_SECTION_SIZE</a>.
40       */
41      long HTTP3_SETTINGS_MAX_FIELD_SECTION_SIZE = 0x6;
42  
43      @Override
44      default long type() {
45          return Http3CodecUtils.HTTP3_SETTINGS_FRAME_TYPE;
46      }
47  
48      /**
49       * Get a setting from the frame.
50       *
51       * @param key   the key of the setting.
52       * @return      the value of the setting or {@code null} if none was found with the given key.
53       */
54      @Nullable
55      Long get(long key);
56  
57      /**
58       * Get a setting from the frame.
59       *
60       * @param key   the key of the setting.
61       * @param defaultValue If the setting does not exist.
62       * @return the value of the setting or {@code defaultValue} if none was found with the given key.
63       */
64      default Long getOrDefault(long key, long defaultValue) {
65          final Long val = get(key);
66          return val == null ? defaultValue : val;
67      }
68  
69      /**
70       * Put a setting in the frame.
71       *
72       * @param key       the key of the setting
73       * @param value     the value of the setting.
74       * @return          the previous stored valued for the given key or {@code null} if none was stored before.
75       */
76      @Nullable
77      Long put(long key, Long value);
78  }