Skip to content

Commit 203d1b0

Browse files
committedApr 5, 2024·
fix(http2): max_header_list_size(num) defaults to 16kb
The HTTP/2 does not define a default. If not defined, hyper still set a high limit of 16mb. However, that seems very high, and most people likely do not think to set it the property. Since hyper tries to protect users, it will now use a default of 16kb. The defaults in hyper are not part of the public API stability promise. Users are encouraged to set options themselves.
1 parent 1c5b1b8 commit 203d1b0

File tree

4 files changed

+4
-5
lines changed

4 files changed

+4
-5
lines changed
 

‎src/client/conn/http2.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -344,7 +344,7 @@ where
344344

345345
/// Sets the max size of received header frames.
346346
///
347-
/// Default is currently 16MB, but can change.
347+
/// Default is currently 16KB, but can change.
348348
pub fn max_header_list_size(&mut self, max: u32) -> &mut Self {
349349
self.h2_builder.max_header_list_size = max;
350350
self

‎src/proto/h2/client.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ const DEFAULT_CONN_WINDOW: u32 = 1024 * 1024 * 5; // 5mb
5151
const DEFAULT_STREAM_WINDOW: u32 = 1024 * 1024 * 2; // 2mb
5252
const DEFAULT_MAX_FRAME_SIZE: u32 = 1024 * 16; // 16kb
5353
const DEFAULT_MAX_SEND_BUF_SIZE: usize = 1024 * 1024; // 1mb
54-
const DEFAULT_MAX_HEADER_LIST_SIZE: u32 = 16 << 20; // 16mb
54+
const DEFAULT_MAX_HEADER_LIST_SIZE: u32 = 1024 * 16; // 16kb
5555

5656
// The maximum number of concurrent streams that the client is allowed to open
5757
// before it receives the initial SETTINGS frame from the server.

‎src/proto/h2/server.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,7 @@ const DEFAULT_CONN_WINDOW: u32 = 1024 * 1024; // 1mb
3838
const DEFAULT_STREAM_WINDOW: u32 = 1024 * 1024; // 1mb
3939
const DEFAULT_MAX_FRAME_SIZE: u32 = 1024 * 16; // 16kb
4040
const DEFAULT_MAX_SEND_BUF_SIZE: usize = 1024 * 400; // 400kb
41-
// 16 MB "sane default" taken from golang http2
42-
const DEFAULT_SETTINGS_MAX_HEADER_LIST_SIZE: u32 = 16 << 20;
41+
const DEFAULT_SETTINGS_MAX_HEADER_LIST_SIZE: u32 = 1024 * 16; // 16kb
4342
const DEFAULT_MAX_LOCAL_ERROR_RESET_STREAMS: usize = 1024;
4443

4544
#[derive(Clone, Debug)]

‎src/server/conn/http2.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -262,7 +262,7 @@ impl<E> Builder<E> {
262262

263263
/// Sets the max size of received header frames.
264264
///
265-
/// Default is currently ~16MB, but may change.
265+
/// Default is currently 16KB, but can change.
266266
pub fn max_header_list_size(&mut self, max: u32) -> &mut Self {
267267
self.h2_builder.max_header_list_size = max;
268268
self

1 commit comments

Comments
 (1)

github-actions[bot] commented on Apr 5, 2024

@github-actions[bot]

⚠️ Performance Alert ⚠️

Possible performance regression was detected for benchmark 'end_to_end'.
Benchmark result of this commit is worse than the previous benchmark result exceeding threshold 2.

Benchmark suite Current: 203d1b0 Previous: df33d4d Ratio
http2_parallel_x10_req_10kb_100_chunks_adaptive_window 41199243 ns/iter (± 42999038) 7950064 ns/iter (± 313327) 5.18

This comment was automatically generated by workflow using github-action-benchmark.

Please sign in to comment.