Commit 6c19b25f authored by Bence Béky's avatar Bence Béky Committed by Commit Bot

Add command line flags to enable greasing HTTP/2.

Multiple server developers approached me either in private or on the
IETF mailing list asking for a way to test this feature.

Bug: 1020233
Change-Id: Ibba5831e8153090b0dde81aa2519dfc75d4f362a
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1894305
Commit-Queue: Ryan Hamilton <rch@chromium.org>
Auto-Submit: Bence Béky <bnc@chromium.org>
Reviewed-by: default avatarRyan Hamilton <rch@chromium.org>
Cr-Commit-Position: refs/heads/master@{#712194}
parent 0005328e
......@@ -135,8 +135,9 @@ void ConfigureHttp2Params(const base::CommandLine& command_line,
// identifier to "grease" settings, see
// https://tools.ietf.org/html/draft-bishop-httpbis-grease-00.
params->http2_settings = GetHttp2Settings(http2_trial_params);
if (GetVariationParam(http2_trial_params, "http2_grease_settings") ==
"true") {
if (command_line.HasSwitch(switches::kHttp2GreaseSettings) ||
GetVariationParam(http2_trial_params, "http2_grease_settings") ==
"true") {
spdy::SpdySettingsId id = 0x0a0a + 0x1000 * base::RandGenerator(0xf + 1) +
0x0010 * base::RandGenerator(0xf + 1);
uint32_t value = base::RandGenerator(
......@@ -146,8 +147,9 @@ void ConfigureHttp2Params(const base::CommandLine& command_line,
// Optionally define a frame of reserved type to "grease" frame types, see
// https://tools.ietf.org/html/draft-bishop-httpbis-grease-00.
if (GetVariationParam(http2_trial_params, "http2_grease_frame_type") ==
"true") {
if (command_line.HasSwitch(switches::kHttp2GreaseFrameType) ||
GetVariationParam(http2_trial_params, "http2_grease_frame_type") ==
"true") {
const uint8_t type = 0x0b + 0x1f * base::RandGenerator(8);
const uint8_t flags =
base::RandGenerator(std::numeric_limits<uint8_t>::max() + 1);
......
......@@ -817,7 +817,23 @@ TEST_F(NetworkSessionConfiguratorTest, QuicHeadersIncludeH2StreamDependency) {
EXPECT_TRUE(params_.quic_params.headers_include_h2_stream_dependency);
}
TEST_F(NetworkSessionConfiguratorTest, Http2GreaseSettings) {
TEST_F(NetworkSessionConfiguratorTest, Http2GreaseSettingsFromCommandLine) {
base::CommandLine command_line(base::CommandLine::NO_PROGRAM);
command_line.AppendSwitch(switches::kHttp2GreaseSettings);
ParseCommandLineAndFieldTrials(command_line);
bool greased_setting_found = false;
for (const auto& setting : params_.http2_settings) {
if ((setting.first & 0x0f0f) == 0x0a0a) {
greased_setting_found = true;
break;
}
}
EXPECT_TRUE(greased_setting_found);
}
TEST_F(NetworkSessionConfiguratorTest, Http2GreaseSettingsFromFieldTrial) {
std::map<std::string, std::string> field_trial_params;
field_trial_params["http2_grease_settings"] = "true";
variations::AssociateVariationParams("HTTP2", "Enabled", field_trial_params);
......@@ -835,7 +851,18 @@ TEST_F(NetworkSessionConfiguratorTest, Http2GreaseSettings) {
EXPECT_TRUE(greased_setting_found);
}
TEST_F(NetworkSessionConfiguratorTest, Http2GreaseFrameType) {
TEST_F(NetworkSessionConfiguratorTest, Http2GreaseFrameTypeFromCommandLine) {
base::CommandLine command_line(base::CommandLine::NO_PROGRAM);
command_line.AppendSwitch(switches::kHttp2GreaseFrameType);
ParseCommandLineAndFieldTrials(command_line);
ASSERT_TRUE(params_.greased_http2_frame);
const uint8_t frame_type = params_.greased_http2_frame.value().type;
EXPECT_EQ(0x0b, frame_type % 0x1f);
}
TEST_F(NetworkSessionConfiguratorTest, Http2GreaseFrameTypeFromFieldTrial) {
std::map<std::string, std::string> field_trial_params;
field_trial_params["http2_grease_frame_type"] = "true";
variations::AssociateVariationParams("HTTP2", "Enabled", field_trial_params);
......
......@@ -61,3 +61,9 @@ NETWORK_SWITCH(kTestingFixedHttpsPort, "testing-fixed-https-port")
// TODO(mmenke): Can we just remove this? host-resolver-rules is more generally
// useful.
NETWORK_SWITCH(kHostRules, "host-rules")
// Enable "greasing" HTTP/2, that is, sending SETTINGS parameters with reserved
// identifiers and sending frames of reserved types, respectively. See
// https://tools.ietf.org/html/draft-bishop-httpbis-grease-00 for more detail.
NETWORK_SWITCH(kHttp2GreaseSettings, "http2-grease-settings")
NETWORK_SWITCH(kHttp2GreaseFrameType, "http2-grease-frame-type")
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment