Skip to content

Commit

Permalink
fix(http2): max_header_list_size(num) defaults to 16kb
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
seanmonstar committed Apr 5, 2024
1 parent 1c5b1b8 commit 203d1b0
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/client/conn/http2.rs
Expand Up @@ -344,7 +344,7 @@ where

/// Sets the max size of received header frames.
///
/// Default is currently 16MB, but can change.
/// Default is currently 16KB, but can change.
pub fn max_header_list_size(&mut self, max: u32) -> &mut Self {
self.h2_builder.max_header_list_size = max;
self
Expand Down
2 changes: 1 addition & 1 deletion src/proto/h2/client.rs
Expand Up @@ -51,7 +51,7 @@ const DEFAULT_CONN_WINDOW: u32 = 1024 * 1024 * 5; // 5mb
const DEFAULT_STREAM_WINDOW: u32 = 1024 * 1024 * 2; // 2mb
const DEFAULT_MAX_FRAME_SIZE: u32 = 1024 * 16; // 16kb
const DEFAULT_MAX_SEND_BUF_SIZE: usize = 1024 * 1024; // 1mb
const DEFAULT_MAX_HEADER_LIST_SIZE: u32 = 16 << 20; // 16mb
const DEFAULT_MAX_HEADER_LIST_SIZE: u32 = 1024 * 16; // 16kb

// The maximum number of concurrent streams that the client is allowed to open
// before it receives the initial SETTINGS frame from the server.
Expand Down
3 changes: 1 addition & 2 deletions src/proto/h2/server.rs
Expand Up @@ -38,8 +38,7 @@ const DEFAULT_CONN_WINDOW: u32 = 1024 * 1024; // 1mb
const DEFAULT_STREAM_WINDOW: u32 = 1024 * 1024; // 1mb
const DEFAULT_MAX_FRAME_SIZE: u32 = 1024 * 16; // 16kb
const DEFAULT_MAX_SEND_BUF_SIZE: usize = 1024 * 400; // 400kb
// 16 MB "sane default" taken from golang http2
const DEFAULT_SETTINGS_MAX_HEADER_LIST_SIZE: u32 = 16 << 20;
const DEFAULT_SETTINGS_MAX_HEADER_LIST_SIZE: u32 = 1024 * 16; // 16kb
const DEFAULT_MAX_LOCAL_ERROR_RESET_STREAMS: usize = 1024;

#[derive(Clone, Debug)]
Expand Down
2 changes: 1 addition & 1 deletion src/server/conn/http2.rs
Expand Up @@ -262,7 +262,7 @@ impl<E> Builder<E> {

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

1 comment on commit 203d1b0

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ 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.