1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
use crate::proto::varint::VarInt;
/// Configures the HTTP/3 connection
#[derive(Debug, Clone, Copy)]
#[non_exhaustive]
pub struct Config {
/// Just like in HTTP/2, HTTP/3 also uses the concept of "grease"
/// to prevent potential interoperability issues in the future.
/// In HTTP/3, the concept of grease is used to ensure that the protocol can evolve
/// and accommodate future changes without breaking existing implementations.
pub(crate) send_grease: bool,
/// The MAX_FIELD_SECTION_SIZE in HTTP/3 refers to the maximum size of the dynamic table used in HPACK compression.
/// HPACK is the compression algorithm used in HTTP/3 to reduce the size of the header fields in HTTP requests and responses.
/// In HTTP/3, the MAX_FIELD_SECTION_SIZE is set to 12.
/// This means that the dynamic table used for HPACK compression can have a maximum size of 2^12 bytes, which is 4KB.
pub(crate) max_field_section_size: u64,
/// https://datatracker.ietf.org/doc/html/draft-ietf-webtrans-http3/#section-3.1
/// Sets `SETTINGS_ENABLE_WEBTRANSPORT` if enabled
pub(crate) enable_webtransport: bool,
/// https://www.rfc-editor.org/info/rfc8441 defines an extended CONNECT method in Section 4,
/// enabled by the SETTINGS_ENABLE_CONNECT_PROTOCOL parameter.
/// That parameter is only defined for HTTP/2.
/// for extended CONNECT in HTTP/3; instead, the SETTINGS_ENABLE_WEBTRANSPORT setting implies that an endpoint supports extended CONNECT.
pub(crate) enable_extended_connect: bool,
/// Enable HTTP Datagrams, see https://datatracker.ietf.org/doc/rfc9297/ for details
pub(crate) enable_datagram: bool,
/// The maximum number of concurrent streams that can be opened by the peer.
pub(crate) max_webtransport_sessions: u64,
}
impl Config {
/// https://datatracker.ietf.org/doc/html/draft-ietf-webtrans-http3/#section-3.1
/// Sets `SETTINGS_ENABLE_WEBTRANSPORT` if enabled
pub fn enable_webtransport(&self) -> bool {
self.enable_webtransport
}
/// Enable HTTP Datagrams, see https://datatracker.ietf.org/doc/rfc9297/ for details
pub fn enable_datagram(&self) -> bool {
self.enable_datagram
}
/// https://www.rfc-editor.org/info/rfc8441 defines an extended CONNECT method in Section 4,
/// enabled by the SETTINGS_ENABLE_CONNECT_PROTOCOL parameter.
/// That parameter is only defined for HTTP/2.
/// for extended CONNECT in HTTP/3; instead, the SETTINGS_ENABLE_WEBTRANSPORT setting implies that an endpoint supports extended CONNECT.
pub fn enable_extended_connect(&self) -> bool {
self.enable_extended_connect
}
}
impl Default for Config {
fn default() -> Self {
Self {
max_field_section_size: VarInt::MAX.0,
send_grease: true,
enable_webtransport: false,
enable_extended_connect: false,
enable_datagram: false,
max_webtransport_sessions: 0,
}
}
}