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 * @deprecated Use {@link Http3SettingIdentifier#HTTP3_SETTINGS_QPACK_MAX_TABLE_CAPACITY} instead.
29 * See <a href="https://tools.ietf.org/html/draft-ietf-quic-qpack-19#section-5">
30 * SETTINGS_QPACK_MAX_TABLE_CAPACITY</a>.
31 */
32 @Deprecated
33 long HTTP3_SETTINGS_QPACK_MAX_TABLE_CAPACITY = Http3SettingIdentifier.HTTP3_SETTINGS_QPACK_MAX_TABLE_CAPACITY.id();
34
35 /**
36 * @deprecated Use {@link Http3SettingIdentifier#HTTP3_SETTINGS_QPACK_BLOCKED_STREAMS} instead.
37 * See <a href="https://tools.ietf.org/html/draft-ietf-quic-qpack-19#section-5">
38 * SETTINGS_QPACK_BLOCKED_STREAMS</a>.
39 */
40 @Deprecated
41 long HTTP3_SETTINGS_QPACK_BLOCKED_STREAMS = Http3SettingIdentifier.HTTP3_SETTINGS_QPACK_BLOCKED_STREAMS.id();
42
43 /**
44 * @deprecated Use {@link Http3SettingIdentifier#HTTP3_SETTINGS_ENABLE_CONNECT_PROTOCOL} instead.
45 * See <a href="https://www.rfc-editor.org/rfc/rfc9220.html#section-5">
46 * SETTINGS_ENABLE_CONNECT_PROTOCOL</a>.
47 */
48 @Deprecated
49 long HTTP3_SETTINGS_ENABLE_CONNECT_PROTOCOL = Http3SettingIdentifier.HTTP3_SETTINGS_ENABLE_CONNECT_PROTOCOL.id();
50
51 /**
52 * @deprecated Use {@link Http3SettingIdentifier#HTTP3_SETTINGS_MAX_FIELD_SECTION_SIZE} instead.
53 * See <a href="https://tools.ietf.org/html/draft-ietf-quic-http-32#section-7.2.4.1">
54 * SETTINGS_MAX_FIELD_SECTION_SIZE</a>.
55 */
56 @Deprecated
57 long HTTP3_SETTINGS_MAX_FIELD_SECTION_SIZE = Http3SettingIdentifier.HTTP3_SETTINGS_MAX_FIELD_SECTION_SIZE.id();
58
59 default Http3Settings settings() {
60 throw new UnsupportedOperationException(
61 "Http3SettingsFrame.settings() not implemented in this version");
62 }
63
64 @Override
65 default long type() {
66 return Http3CodecUtils.HTTP3_SETTINGS_FRAME_TYPE;
67 }
68
69 /**
70 * Get a setting from the frame.
71 *
72 * @param key the key of the setting.
73 * @return the value of the setting or {@code null} if none was found with the given key.
74 * @deprecated Use typed accessors via {@link #settings()} instead.
75 * For example, {@code frame.settings().connectProtocolEnabled()}.
76 */
77 @Deprecated
78 @Nullable
79 default Long get(long key) {
80 return settings().get(key);
81 }
82
83 /**
84 * Get a setting from the frame.
85 *
86 * @param key the key of the setting.
87 * @param defaultValue If the setting does not exist.
88 * @return the value of the setting or {@code defaultValue} if none was found with the given key.
89 * @deprecated Use typed accessors via {@link #settings()} instead.
90 * * For example, {@code frame.settings().qpackBlockedStreams()}.
91 */
92 @Deprecated
93 default Long getOrDefault(long key, long defaultValue) {
94 final Long val = get(key);
95 return val == null ? defaultValue : val;
96 }
97
98 /**
99 * Put a setting in the frame.
100 *
101 * @param key the key of the setting
102 * @param value the value of the setting.
103 * @return the previous stored valued for the given key or {@code null} if none was stored before.
104 * @deprecated Use typed accessors via {@link #settings()} instead.
105 * * For example, {@code frame.settings().enableConnectProtocol(true)}.
106 */
107 @Nullable
108 default Long put(long key, Long value) {
109 return settings().put(key, value);
110 }
111 }