Add --http2-recv-window option

This commit is contained in:
klzgrad 2024-09-08 09:32:53 +08:00
parent 8b2599211f
commit 9b7d6038ea
3 changed files with 30 additions and 2 deletions

View File

@ -266,6 +266,26 @@ bool NaiveConfig::Parse(const base::Value::Dict& value) {
no_post_quantum = true; no_post_quantum = true;
} }
if (const base::Value* v = value.Find("http2-recv-window")) {
if (std::optional<int> i = v->GetIfInt()) {
http2_recv_window = *i;
} else if (const std::string* str = v->GetIfString()) {
int http2_recv_window_int;
if (!base::StringToInt(*str, &http2_recv_window_int)) {
std::cerr << "Invalid http2-recv-window" << std::endl;
return false;
}
http2_recv_window = http2_recv_window_int;
} else {
std::cerr << "Invalid http2-recv-window" << std::endl;
return false;
}
if (http2_recv_window.has_value() && *http2_recv_window <= 0) {
std::cerr << "Invalid http2-recv-window" << std::endl;
return false;
}
}
return true; return true;
} }

View File

@ -62,6 +62,8 @@ struct NaiveConfig {
std::optional<bool> no_post_quantum; std::optional<bool> no_post_quantum;
std::optional<int> http2_recv_window;
NaiveConfig(); NaiveConfig();
NaiveConfig(const NaiveConfig&); NaiveConfig(const NaiveConfig&);
~NaiveConfig(); ~NaiveConfig();

View File

@ -197,11 +197,17 @@ std::unique_ptr<URLRequestContext> BuildURLRequestContext(
// The windows size should be twice the BDP because WINDOW_UPDATEs // The windows size should be twice the BDP because WINDOW_UPDATEs
// are sent after half the window is unacknowledged. // are sent after half the window is unacknowledged.
constexpr int kTypicalWindow = kMaxBdpMB * 2 * 1024 * 1024; constexpr int kTypicalWindow = kMaxBdpMB * 2 * 1024 * 1024;
int http2_window_size = kTypicalWindow;
if (config.http2_recv_window.has_value()) {
http2_window_size = *config.http2_recv_window;
LOG(INFO) << "Overriding HTTP/2 receive window size as "
<< http2_window_size;
}
HttpNetworkSessionParams http_network_session_params; HttpNetworkSessionParams http_network_session_params;
http_network_session_params.spdy_session_max_recv_window_size = http_network_session_params.spdy_session_max_recv_window_size =
kTypicalWindow * 2; http2_window_size * 5 / 2;
http_network_session_params http_network_session_params
.http2_settings[spdy::SETTINGS_INITIAL_WINDOW_SIZE] = kTypicalWindow; .http2_settings[spdy::SETTINGS_INITIAL_WINDOW_SIZE] = http2_window_size;
builder.set_http_network_session_params(http_network_session_params); builder.set_http_network_session_params(http_network_session_params);
builder.set_net_log(net_log); builder.set_net_log(net_log);