Skip to content

Commit

Permalink
Add --http2-recv-window option
Browse files Browse the repository at this point in the history
  • Loading branch information
klzgrad committed Sep 8, 2024
1 parent 8b25992 commit 9b7d603
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 2 deletions.
20 changes: 20 additions & 0 deletions src/net/tools/naive/naive_config.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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<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;
}

Expand Down
2 changes: 2 additions & 0 deletions src/net/tools/naive/naive_config.h
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,8 @@ struct NaiveConfig {

std::optional<bool> no_post_quantum;

std::optional<int> http2_recv_window;

NaiveConfig();
NaiveConfig(const NaiveConfig&);
~NaiveConfig();
Expand Down
10 changes: 8 additions & 2 deletions src/net/tools/naive/naive_proxy_bin.cc
Original file line number Diff line number Diff line change
Expand Up @@ -197,11 +197,17 @@ std::unique_ptr<URLRequestContext> 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);
Expand Down

0 comments on commit 9b7d603

Please sign in to comment.