diff --git a/src/net/tools/naive/naive_config.cc b/src/net/tools/naive/naive_config.cc index 8d5b36aba4..5ec3864326 100644 --- a/src/net/tools/naive/naive_config.cc +++ b/src/net/tools/naive/naive_config.cc @@ -266,6 +266,26 @@ bool NaiveConfig::Parse(const base::Value::Dict& value) { no_post_quantum = true; } + if (const base::Value* v = value.Find("http2-recv-window")) { + if (std::optional 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; } diff --git a/src/net/tools/naive/naive_config.h b/src/net/tools/naive/naive_config.h index 186fca1b2f..626d38fff3 100644 --- a/src/net/tools/naive/naive_config.h +++ b/src/net/tools/naive/naive_config.h @@ -62,6 +62,8 @@ struct NaiveConfig { std::optional no_post_quantum; + std::optional http2_recv_window; + NaiveConfig(); NaiveConfig(const NaiveConfig&); ~NaiveConfig(); diff --git a/src/net/tools/naive/naive_proxy_bin.cc b/src/net/tools/naive/naive_proxy_bin.cc index 080be85215..a4b889fc0f 100644 --- a/src/net/tools/naive/naive_proxy_bin.cc +++ b/src/net/tools/naive/naive_proxy_bin.cc @@ -197,11 +197,17 @@ std::unique_ptr BuildURLRequestContext( // The windows size should be twice the BDP because WINDOW_UPDATEs // are sent after half the window is unacknowledged. 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; http_network_session_params.spdy_session_max_recv_window_size = - kTypicalWindow * 2; + http2_window_size * 5 / 2; 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_net_log(net_log);