blob: 0f920228fe7d252ad27f6e2cf4402fd62f7d870e [file] [log] [blame]
xunjielif24ee5f2015-11-23 18:05:261// Copyright 2015 The Chromium Authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5#include "components/cronet/url_request_context_config.h"
6
Gyuyoung Kim6afb5082018-01-19 13:35:577#include <memory>
8
Eric Orthe1cdd902019-02-26 02:52:469#include "base/bind.h"
Julia Tuttle3cc27a4a2018-04-25 15:57:0610#include "base/json/json_writer.h"
Eric Orthe1cdd902019-02-26 02:52:4611#include "base/logging.h"
Douglas Creagera220947e2018-08-23 20:08:5312#include "base/strings/string_piece.h"
mmenke51629db12017-06-28 13:34:1213#include "base/test/scoped_task_environment.h"
Douglas Creagera220947e2018-08-23 20:08:5314#include "base/test/values_test_util.h"
tfhef3618f2016-01-11 23:07:0815#include "base/values.h"
Zhongyi Shiaa518c22018-06-15 04:37:3616#include "build/build_config.h"
Eric Orthe1cdd902019-02-26 02:52:4617#include "net/base/host_port_pair.h"
Matt Menked732ea42019-03-08 12:05:0018#include "net/base/http_user_agent_settings.h"
Eric Orthe1cdd902019-02-26 02:52:4619#include "net/base/net_errors.h"
pauljensen9041eb3c2015-12-09 12:29:0120#include "net/cert/cert_verifier.h"
Eric Orthe1cdd902019-02-26 02:52:4621#include "net/dns/host_resolver.h"
Eric Orth607b6d82019-05-08 16:43:3222#include "net/dns/host_resolver_manager.h"
xunjielif24ee5f2015-11-23 18:05:2623#include "net/http/http_network_session.h"
mikecironef22f9812016-10-04 03:40:1924#include "net/log/net_log.h"
25#include "net/log/net_log_with_source.h"
Lily Houghton582d4622018-01-22 22:43:4026#include "net/proxy_resolution/proxy_config.h"
27#include "net/proxy_resolution/proxy_config_service_fixed.h"
xunjielif24ee5f2015-11-23 18:05:2628#include "net/url_request/url_request_context.h"
29#include "net/url_request/url_request_context_builder.h"
30#include "testing/gtest/include/gtest/gtest.h"
31
Douglas Creagera220947e2018-08-23 20:08:5332#if BUILDFLAG(ENABLE_REPORTING)
33#include "net/network_error_logging/network_error_logging_service.h"
34#include "net/reporting/reporting_service.h"
35#endif // BUILDFLAG(ENABLE_REPORTING)
36
xunjielif24ee5f2015-11-23 18:05:2637namespace cronet {
38
Douglas Creagera220947e2018-08-23 20:08:5339namespace {
40
Douglas Creagera220947e2018-08-23 20:08:5341std::string WrapJsonHeader(base::StringPiece value) {
42 std::string result;
43 result.reserve(value.size() + 2);
44 result.push_back('[');
45 value.AppendToString(&result);
46 result.push_back(']');
47 return result;
48}
49
50// Returns whether two JSON-encoded headers contain the same content, ignoring
51// irrelevant encoding issues like whitespace and map element ordering.
52bool JsonHeaderEquals(base::StringPiece expected, base::StringPiece actual) {
Lei Zhang9b9d5792019-02-20 07:24:4253 return base::test::ParseJson(WrapJsonHeader(expected)) ==
54 base::test::ParseJson(WrapJsonHeader(actual));
Douglas Creagera220947e2018-08-23 20:08:5355}
56
57} // namespace
58
mmenke51629db12017-06-28 13:34:1259TEST(URLRequestContextConfigTest, TestExperimentalOptionParsing) {
60 base::test::ScopedTaskEnvironment scoped_task_environment_(
61 base::test::ScopedTaskEnvironment::MainThreadType::IO);
62
Julia Tuttle3cc27a4a2018-04-25 15:57:0663 // Create JSON for experimental options.
64 base::DictionaryValue options;
65 options.SetPath({"QUIC", "max_server_configs_stored_in_properties"},
66 base::Value(2));
67 options.SetPath({"QUIC", "user_agent_id"}, base::Value("Custom QUIC UAID"));
68 options.SetPath({"QUIC", "idle_connection_timeout_seconds"},
69 base::Value(300));
70 options.SetPath({"QUIC", "close_sessions_on_ip_change"}, base::Value(true));
71 options.SetPath({"QUIC", "race_cert_verification"}, base::Value(true));
72 options.SetPath({"QUIC", "connection_options"}, base::Value("TIME,TBBR,REJ"));
73 options.SetPath({"AsyncDNS", "enable"}, base::Value(true));
74 options.SetPath({"NetworkErrorLogging", "enable"}, base::Value(true));
Douglas Creagera220947e2018-08-23 20:08:5375 options.SetPath({"NetworkErrorLogging", "preloaded_report_to_headers"},
Lei Zhang9b9d5792019-02-20 07:24:4276 base::test::ParseJson(R"json(
Douglas Creagera220947e2018-08-23 20:08:5377 [
78 {
79 "origin": "https://test-origin/",
80 "value": {
81 "group": "test-group",
82 "max_age": 86400,
83 "endpoints": [
84 {"url": "https://test-endpoint/"},
85 ],
86 },
87 },
88 {
89 "origin": "https://test-origin-2/",
90 "value": [
91 {
92 "group": "test-group-2",
93 "max_age": 86400,
94 "endpoints": [
95 {"url": "https://test-endpoint-2/"},
96 ],
97 },
98 {
99 "group": "test-group-3",
100 "max_age": 86400,
101 "endpoints": [
102 {"url": "https://test-endpoint-3/"},
103 ],
104 },
105 ],
106 },
107 {
108 "origin": "https://value-is-missing/",
109 },
110 {
111 "value": "origin is missing",
112 },
113 {
114 "origin": 123,
115 "value": "origin is not a string",
116 },
117 {
118 "origin": "this is not a URL",
119 "value": "origin not a URL",
120 },
121 ]
122 )json"));
123 options.SetPath({"NetworkErrorLogging", "preloaded_nel_headers"},
Lei Zhang9b9d5792019-02-20 07:24:42124 base::test::ParseJson(R"json(
Douglas Creagera220947e2018-08-23 20:08:53125 [
126 {
127 "origin": "https://test-origin/",
128 "value": {
129 "report_to": "test-group",
130 "max_age": 86400,
131 },
132 },
133 ]
134 )json"));
Julia Tuttle3cc27a4a2018-04-25 15:57:06135 options.SetPath({"UnknownOption", "foo"}, base::Value(true));
136 options.SetPath({"HostResolverRules", "host_resolver_rules"},
137 base::Value("MAP * 127.0.0.1"));
138 // See http://crbug.com/696569.
139 options.SetKey("disable_ipv6_on_wifi", base::Value(true));
140 std::string options_json;
141 EXPECT_TRUE(base::JSONWriter::Write(options, &options_json));
142
pauljensen9041eb3c2015-12-09 12:29:01143 URLRequestContextConfig config(
144 // Enable QUIC.
145 true,
mefc5da5712016-02-09 20:14:23146 // QUIC User Agent ID.
147 "Default QUIC User Agent ID",
pauljensen9041eb3c2015-12-09 12:29:01148 // Enable SPDY.
149 true,
xunjieli186d2bf2017-04-18 13:45:47150 // Enable Brotli.
151 false,
pauljensen9041eb3c2015-12-09 12:29:01152 // Type of http cache.
153 URLRequestContextConfig::HttpCacheType::DISK,
154 // Max size of http cache in bytes.
155 1024000,
156 // Disable caching for HTTP responses. Other information may be stored in
157 // the cache.
158 false,
159 // Storage path for http cache and cookie storage.
160 "/data/data/org.chromium.net/app_cronet_test/test_storage",
Misha Efimovd4ab38302018-01-30 23:56:42161 // Accept-Language request header field.
162 "foreign-language",
pauljensen9041eb3c2015-12-09 12:29:01163 // User-Agent request header field.
164 "fake agent",
165 // JSON encoded experimental options.
Julia Tuttle3cc27a4a2018-04-25 15:57:06166 options_json,
pauljensen9041eb3c2015-12-09 12:29:01167 // MockCertVerifier to use for testing purposes.
tbansal7018e2a2016-06-25 00:40:39168 std::unique_ptr<net::CertVerifier>(),
169 // Enable network quality estimator.
kapishnikov385aa422016-07-01 20:53:02170 false,
171 // Enable Public Key Pinning bypass for local trust anchors.
Paul Jensen6a1ea3a2018-08-24 14:46:41172 true,
173 // Optional network thread priority.
174 base::Optional<double>(42.0));
xunjielif24ee5f2015-11-23 18:05:26175
xunjielif24ee5f2015-11-23 18:05:26176 net::URLRequestContextBuilder builder;
pauljensene92c4092015-12-09 19:13:48177 net::NetLog net_log;
David Benjamindc2f4b02017-07-27 23:59:02178 config.ConfigureURLRequestContextBuilder(&builder, &net_log);
xunjielid67295e2017-03-16 21:05:41179 EXPECT_FALSE(config.effective_experimental_options->HasKey("UnknownOption"));
xunjielif24ee5f2015-11-23 18:05:26180 // Set a ProxyConfigService to avoid DCHECK failure when building.
ricea85ec57952016-08-31 09:34:10181 builder.set_proxy_config_service(
Lily Houghtonef028852017-12-06 20:52:30182 std::make_unique<net::ProxyConfigServiceFixed>(
Ramin Halavatica8d5252018-03-12 05:33:49183 net::ProxyConfigWithAnnotation::CreateDirect()));
dchengfe3745e6242016-04-21 23:49:58184 std::unique_ptr<net::URLRequestContext> context(builder.Build());
xunjielif24ee5f2015-11-23 18:05:26185 const net::HttpNetworkSession::Params* params =
186 context->GetNetworkSessionParams();
187 // Check Quic Connection options.
Ryan Hamilton8d9ee76e2018-05-29 23:52:52188 quic::QuicTagVector quic_connection_options;
189 quic_connection_options.push_back(quic::kTIME);
190 quic_connection_options.push_back(quic::kTBBR);
191 quic_connection_options.push_back(quic::kREJ);
xunjielif24ee5f2015-11-23 18:05:26192 EXPECT_EQ(quic_connection_options, params->quic_connection_options);
193
mefc5da5712016-02-09 20:14:23194 // Check Custom QUIC User Agent Id.
195 EXPECT_EQ("Custom QUIC UAID", params->quic_user_agent_id);
196
rtenneti6971c172016-01-15 20:12:10197 // Check max_server_configs_stored_in_properties.
198 EXPECT_EQ(2u, params->quic_max_server_configs_stored_in_properties);
xunjielif24ee5f2015-11-23 18:05:26199
rtenneti64e809d02015-12-11 00:26:20200 // Check idle_connection_timeout_seconds.
201 EXPECT_EQ(300, params->quic_idle_connection_timeout_seconds);
202
Jana Iyengar903dec22017-11-28 00:44:23203 EXPECT_TRUE(params->quic_close_sessions_on_ip_change);
Zhongyi Shi63574b72018-06-01 20:22:25204 EXPECT_FALSE(params->quic_goaway_sessions_on_ip_change);
Zhongyi Shi8ff38c12018-02-22 00:02:30205 EXPECT_FALSE(params->quic_allow_server_migration);
Zhongyi Shi64795622017-11-20 02:21:49206 EXPECT_FALSE(params->quic_migrate_sessions_on_network_change_v2);
Zhongyi Shif4683a32017-12-01 00:03:28207 EXPECT_FALSE(params->quic_migrate_sessions_early_v2);
Zhongyi Shi32fe14d42019-02-28 00:25:36208 EXPECT_FALSE(params->quic_migrate_idle_sessions);
Zhongyi Shiff359581bc2018-09-26 18:11:48209 EXPECT_FALSE(params->quic_retry_on_alternate_network_before_handshake);
Renjie94b90712018-10-18 21:03:19210 EXPECT_FALSE(params->quic_race_stale_dns_on_connection);
jrid26566952016-02-04 21:06:42211
rtennetid073dd22016-08-04 01:58:33212 // Check race_cert_verification.
213 EXPECT_TRUE(params->quic_race_cert_verification);
214
Misha Efimov63957912017-12-06 07:13:26215#if defined(ENABLE_BUILT_IN_DNS)
216 // Check AsyncDNS resolver is enabled (not supported on iOS).
tfhef3618f2016-01-11 23:07:08217 EXPECT_TRUE(context->host_resolver()->GetDnsConfigAsValue());
Misha Efimov63957912017-12-06 07:13:26218#endif // defined(ENABLE_BUILT_IN_DNS)
mgershaf2c12c2016-08-22 16:33:54219
Julia Tuttle9715d1642018-01-29 17:02:26220#if BUILDFLAG(ENABLE_REPORTING)
221 // Check Reporting and Network Error Logging are enabled (can be disabled at
222 // build time).
223 EXPECT_TRUE(context->reporting_service());
Julia Tuttlecba7d222018-02-23 19:37:27224 EXPECT_TRUE(context->network_error_logging_service());
Julia Tuttle9715d1642018-01-29 17:02:26225#endif // BUILDFLAG(ENABLE_REPORTING)
226
Douglas Creagera220947e2018-08-23 20:08:53227 ASSERT_EQ(2u, config.preloaded_report_to_headers.size());
228 EXPECT_EQ(url::Origin::CreateFromNormalizedTuple("https", "test-origin", 443),
229 config.preloaded_report_to_headers[0].origin);
230 EXPECT_TRUE(JsonHeaderEquals( //
231 R"json(
232 {
233 "group": "test-group",
234 "max_age": 86400,
235 "endpoints": [
236 {"url": "https://test-endpoint/"},
237 ],
238 }
239 )json",
240 config.preloaded_report_to_headers[0].value));
241 EXPECT_EQ(
242 url::Origin::CreateFromNormalizedTuple("https", "test-origin-2", 443),
243 config.preloaded_report_to_headers[1].origin);
244 EXPECT_TRUE(JsonHeaderEquals( //
245 R"json(
246 {
247 "group": "test-group-2",
248 "max_age": 86400,
249 "endpoints": [
250 {"url": "https://test-endpoint-2/"},
251 ],
252 },
253 {
254 "group": "test-group-3",
255 "max_age": 86400,
256 "endpoints": [
257 {"url": "https://test-endpoint-3/"},
258 ],
259 }
260 )json",
261 config.preloaded_report_to_headers[1].value));
262
263 ASSERT_EQ(1u, config.preloaded_nel_headers.size());
264 EXPECT_EQ(url::Origin::CreateFromNormalizedTuple("https", "test-origin", 443),
265 config.preloaded_nel_headers[0].origin);
266 EXPECT_TRUE(JsonHeaderEquals( //
267 R"json(
268 {
269 "report_to": "test-group",
270 "max_age": 86400,
271 }
272 )json",
273 config.preloaded_nel_headers[0].value));
274
mgershaf9a9232017-04-13 20:19:03275 // Check IPv6 is disabled when on wifi.
Eric Orth607b6d82019-05-08 16:43:32276 EXPECT_FALSE(context->host_resolver()
277 ->GetManagerForTesting()
278 ->check_ipv6_on_wifi_for_testing());
mgershb3fe8082017-02-28 20:09:20279
Eric Orthe1cdd902019-02-26 02:52:46280 // All host resolution expected to be mapped to an immediately-resolvable IP.
281 std::unique_ptr<net::HostResolver::ResolveHostRequest> resolve_request =
282 context->host_resolver()->CreateRequest(net::HostPortPair("abcde", 80),
283 net::NetLogWithSource(),
284 base::nullopt);
285 EXPECT_EQ(net::OK, resolve_request->Start(
286 base::BindOnce([](int error) { NOTREACHED(); })));
Paul Jensen6a1ea3a2018-08-24 14:46:41287
288 EXPECT_TRUE(config.network_thread_priority);
289 EXPECT_EQ(42.0, config.network_thread_priority.value());
xunjielif24ee5f2015-11-23 18:05:26290}
291
Zhongyi Shi57247962018-11-05 20:03:52292TEST(URLRequestContextConfigTest, SetSupportedQuicVersion) {
293 base::test::ScopedTaskEnvironment scoped_task_environment_(
294 base::test::ScopedTaskEnvironment::MainThreadType::IO);
295
296 URLRequestContextConfig config(
297 // Enable QUIC.
298 true,
299 // QUIC User Agent ID.
300 "Default QUIC User Agent ID",
301 // Enable SPDY.
302 true,
303 // Enable Brotli.
304 false,
305 // Type of http cache.
306 URLRequestContextConfig::HttpCacheType::DISK,
307 // Max size of http cache in bytes.
308 1024000,
309 // Disable caching for HTTP responses. Other information may be stored in
310 // the cache.
311 false,
312 // Storage path for http cache and cookie storage.
313 "/data/data/org.chromium.net/app_cronet_test/test_storage",
314 // Accept-Language request header field.
315 "foreign-language",
316 // User-Agent request header field.
317 "fake agent",
318 // JSON encoded experimental options.
319 "{\"QUIC\":{\"quic_version\":\"QUIC_VERSION_44\"}}",
320 // MockCertVerifier to use for testing purposes.
321 std::unique_ptr<net::CertVerifier>(),
322 // Enable network quality estimator.
323 false,
324 // Enable Public Key Pinning bypass for local trust anchors.
325 true,
326 // Optional network thread priority.
327 base::Optional<double>());
328
329 net::URLRequestContextBuilder builder;
330 net::NetLog net_log;
331 config.ConfigureURLRequestContextBuilder(&builder, &net_log);
332 // Set a ProxyConfigService to avoid DCHECK failure when building.
333 builder.set_proxy_config_service(
334 std::make_unique<net::ProxyConfigServiceFixed>(
335 net::ProxyConfigWithAnnotation::CreateDirect()));
336 std::unique_ptr<net::URLRequestContext> context(builder.Build());
337 const net::HttpNetworkSession::Params* params =
338 context->GetNetworkSessionParams();
339 EXPECT_EQ(params->quic_supported_versions.size(), 1u);
Nick Harper23290b82019-05-02 00:02:56340 EXPECT_EQ(params->quic_supported_versions[0],
341 quic::ParsedQuicVersion(quic::PROTOCOL_QUIC_CRYPTO,
342 quic::QUIC_VERSION_44));
Zhongyi Shi57247962018-11-05 20:03:52343}
344
345TEST(URLRequestContextConfigTest, SetUnsupportedQuicVersion) {
346 base::test::ScopedTaskEnvironment scoped_task_environment_(
347 base::test::ScopedTaskEnvironment::MainThreadType::IO);
348
349 URLRequestContextConfig config(
350 // Enable QUIC.
351 true,
352 // QUIC User Agent ID.
353 "Default QUIC User Agent ID",
354 // Enable SPDY.
355 true,
356 // Enable Brotli.
357 false,
358 // Type of http cache.
359 URLRequestContextConfig::HttpCacheType::DISK,
360 // Max size of http cache in bytes.
361 1024000,
362 // Disable caching for HTTP responses. Other information may be stored in
363 // the cache.
364 false,
365 // Storage path for http cache and cookie storage.
366 "/data/data/org.chromium.net/app_cronet_test/test_storage",
367 // Accept-Language request header field.
368 "foreign-language",
369 // User-Agent request header field.
370 "fake agent",
371 // JSON encoded experimental options.
372 "{\"QUIC\":{\"quic_version\":\"QUIC_VERSION_33\"}}",
373 // MockCertVerifier to use for testing purposes.
374 std::unique_ptr<net::CertVerifier>(),
375 // Enable network quality estimator.
376 false,
377 // Enable Public Key Pinning bypass for local trust anchors.
378 true,
379 // Optional network thread priority.
380 base::Optional<double>());
381
382 net::URLRequestContextBuilder builder;
383 net::NetLog net_log;
384 config.ConfigureURLRequestContextBuilder(&builder, &net_log);
385 // Set a ProxyConfigService to avoid DCHECK failure when building.
386 builder.set_proxy_config_service(
387 std::make_unique<net::ProxyConfigServiceFixed>(
388 net::ProxyConfigWithAnnotation::CreateDirect()));
389 std::unique_ptr<net::URLRequestContext> context(builder.Build());
390 const net::HttpNetworkSession::Params* params =
391 context->GetNetworkSessionParams();
392 EXPECT_EQ(params->quic_supported_versions.size(), 1u);
Nick Harper23290b82019-05-02 00:02:56393 EXPECT_EQ(params->quic_supported_versions[0],
394 quic::ParsedQuicVersion(quic::PROTOCOL_QUIC_CRYPTO,
395 quic::QUIC_VERSION_43));
Zhongyi Shi57247962018-11-05 20:03:52396}
397
Zhongyi Shi8ff38c12018-02-22 00:02:30398TEST(URLRequestContextConfigTest, SetQuicServerMigrationOptions) {
399 base::test::ScopedTaskEnvironment scoped_task_environment_(
400 base::test::ScopedTaskEnvironment::MainThreadType::IO);
401
402 URLRequestContextConfig config(
403 // Enable QUIC.
404 true,
405 // QUIC User Agent ID.
406 "Default QUIC User Agent ID",
407 // Enable SPDY.
408 true,
409 // Enable Brotli.
410 false,
411 // Type of http cache.
412 URLRequestContextConfig::HttpCacheType::DISK,
413 // Max size of http cache in bytes.
414 1024000,
415 // Disable caching for HTTP responses. Other information may be stored in
416 // the cache.
417 false,
418 // Storage path for http cache and cookie storage.
419 "/data/data/org.chromium.net/app_cronet_test/test_storage",
420 // Accept-Language request header field.
421 "foreign-language",
422 // User-Agent request header field.
423 "fake agent",
424 // JSON encoded experimental options.
425 "{\"QUIC\":{\"allow_server_migration\":true}}",
426 // MockCertVerifier to use for testing purposes.
427 std::unique_ptr<net::CertVerifier>(),
428 // Enable network quality estimator.
429 false,
430 // Enable Public Key Pinning bypass for local trust anchors.
Paul Jensen6a1ea3a2018-08-24 14:46:41431 true,
432 // Optional network thread priority.
433 base::Optional<double>());
Zhongyi Shi8ff38c12018-02-22 00:02:30434
435 net::URLRequestContextBuilder builder;
436 net::NetLog net_log;
437 config.ConfigureURLRequestContextBuilder(&builder, &net_log);
438 // Set a ProxyConfigService to avoid DCHECK failure when building.
439 builder.set_proxy_config_service(
440 std::make_unique<net::ProxyConfigServiceFixed>(
Ramin Halavatica8d5252018-03-12 05:33:49441 net::ProxyConfigWithAnnotation::CreateDirect()));
Zhongyi Shi8ff38c12018-02-22 00:02:30442 std::unique_ptr<net::URLRequestContext> context(builder.Build());
443 const net::HttpNetworkSession::Params* params =
444 context->GetNetworkSessionParams();
445
446 EXPECT_FALSE(params->quic_close_sessions_on_ip_change);
447 EXPECT_TRUE(params->quic_allow_server_migration);
448}
449
Zhongyi Shiaa518c22018-06-15 04:37:36450// Test that goaway_sessions_on_ip_change is set on by default for iOS.
451#if defined(OS_IOS)
452#define MAYBE_SetQuicGoAwaySessionsOnIPChangeByDefault \
453 SetQuicGoAwaySessionsOnIPChangeByDefault
454#else
455#define MAYBE_SetQuicGoAwaySessionsOnIPChangeByDefault \
456 DISABLED_SetQuicGoAwaySessionsOnIPChangeByDefault
457#endif
458TEST(URLRequestContextConfigTest,
459 MAYBE_SetQuicGoAwaySessionsOnIPChangeByDefault) {
460 base::test::ScopedTaskEnvironment scoped_task_environment_(
461 base::test::ScopedTaskEnvironment::MainThreadType::IO);
462
463 URLRequestContextConfig config(
464 // Enable QUIC.
465 true,
466 // QUIC User Agent ID.
467 "Default QUIC User Agent ID",
468 // Enable SPDY.
469 true,
470 // Enable Brotli.
471 false,
472 // Type of http cache.
473 URLRequestContextConfig::HttpCacheType::DISK,
474 // Max size of http cache in bytes.
475 1024000,
476 // Disable caching for HTTP responses. Other information may be stored in
477 // the cache.
478 false,
479 // Storage path for http cache and cookie storage.
480 "/data/data/org.chromium.net/app_cronet_test/test_storage",
481 // Accept-Language request header field.
482 "foreign-language",
483 // User-Agent request header field.
484 "fake agent",
485 // JSON encoded experimental options.
486 "{\"QUIC\":{}}",
487 // MockCertVerifier to use for testing purposes.
488 std::unique_ptr<net::CertVerifier>(),
489 // Enable network quality estimator.
490 false,
491 // Enable Public Key Pinning bypass for local trust anchors.
Paul Jensen6a1ea3a2018-08-24 14:46:41492 true,
493 // Optional network thread priority.
494 base::Optional<double>());
Zhongyi Shiaa518c22018-06-15 04:37:36495
496 net::URLRequestContextBuilder builder;
497 net::NetLog net_log;
498 config.ConfigureURLRequestContextBuilder(&builder, &net_log);
499 // Set a ProxyConfigService to avoid DCHECK failure when building.
500 builder.set_proxy_config_service(
501 std::make_unique<net::ProxyConfigServiceFixed>(
502 net::ProxyConfigWithAnnotation::CreateDirect()));
503 std::unique_ptr<net::URLRequestContext> context(builder.Build());
504 const net::HttpNetworkSession::Params* params =
505 context->GetNetworkSessionParams();
506
507 EXPECT_FALSE(params->quic_close_sessions_on_ip_change);
508 EXPECT_TRUE(params->quic_goaway_sessions_on_ip_change);
509}
510
511// Tests that goaway_sessions_on_ip_changes can be set on via
512// experimental options on non-iOS.
513#if !defined(OS_IOS)
514#define MAYBE_SetQuicGoAwaySessionsOnIPChangeViaExperimentOptions \
515 SetQuicGoAwaySessionsOnIPChangeViaExperimentOptions
516#else
517#define MAYBE_SetQuicGoAwaySessionsOnIPChangeViaExperimentOptions \
518 DISABLED_SetQuicGoAwaySessionsOnIPChangeViaExperimentOptions
519#endif
520TEST(URLRequestContextConfigTest,
521 MAYBE_SetQuicGoAwaySessionsOnIPChangeViaExperimentOptions) {
Zhongyi Shi63574b72018-06-01 20:22:25522 base::test::ScopedTaskEnvironment scoped_task_environment_(
523 base::test::ScopedTaskEnvironment::MainThreadType::IO);
524
525 URLRequestContextConfig config(
526 // Enable QUIC.
527 true,
528 // QUIC User Agent ID.
529 "Default QUIC User Agent ID",
530 // Enable SPDY.
531 true,
532 // Enable Brotli.
533 false,
534 // Type of http cache.
535 URLRequestContextConfig::HttpCacheType::DISK,
536 // Max size of http cache in bytes.
537 1024000,
538 // Disable caching for HTTP responses. Other information may be stored in
539 // the cache.
540 false,
541 // Storage path for http cache and cookie storage.
542 "/data/data/org.chromium.net/app_cronet_test/test_storage",
543 // Accept-Language request header field.
544 "foreign-language",
545 // User-Agent request header field.
546 "fake agent",
547 // JSON encoded experimental options.
548 "{\"QUIC\":{\"goaway_sessions_on_ip_change\":true}}",
549 // MockCertVerifier to use for testing purposes.
550 std::unique_ptr<net::CertVerifier>(),
551 // Enable network quality estimator.
552 false,
553 // Enable Public Key Pinning bypass for local trust anchors.
Paul Jensen6a1ea3a2018-08-24 14:46:41554 true,
555 // Optional network thread priority.
556 base::Optional<double>());
Zhongyi Shi63574b72018-06-01 20:22:25557
558 net::URLRequestContextBuilder builder;
559 net::NetLog net_log;
560 config.ConfigureURLRequestContextBuilder(&builder, &net_log);
561 // Set a ProxyConfigService to avoid DCHECK failure when building.
562 builder.set_proxy_config_service(
563 std::make_unique<net::ProxyConfigServiceFixed>(
564 net::ProxyConfigWithAnnotation::CreateDirect()));
565 std::unique_ptr<net::URLRequestContext> context(builder.Build());
566 const net::HttpNetworkSession::Params* params =
567 context->GetNetworkSessionParams();
568
569 EXPECT_FALSE(params->quic_close_sessions_on_ip_change);
570 EXPECT_TRUE(params->quic_goaway_sessions_on_ip_change);
571}
572
Zhongyi Shiaa518c22018-06-15 04:37:36573// Test that goaway_sessions_on_ip_change can be set to false via
574// exprimental options on iOS.
575#if defined(OS_IOS)
576#define MAYBE_DisableQuicGoAwaySessionsOnIPChangeViaExperimentOptions \
577 DisableQuicGoAwaySessionsOnIPChangeViaExperimentOptions
578#else
579#define MAYBE_DisableQuicGoAwaySessionsOnIPChangeViaExperimentOptions \
580 DISABLED_DisableQuicGoAwaySessionsOnIPChangeViaExperimentOptions
581#endif
582TEST(URLRequestContextConfigTest,
583 MAYBE_DisableQuicGoAwaySessionsOnIPChangeViaExperimentOptions) {
584 base::test::ScopedTaskEnvironment scoped_task_environment_(
585 base::test::ScopedTaskEnvironment::MainThreadType::IO);
586
587 URLRequestContextConfig config(
588 // Enable QUIC.
589 true,
590 // QUIC User Agent ID.
591 "Default QUIC User Agent ID",
592 // Enable SPDY.
593 true,
594 // Enable Brotli.
595 false,
596 // Type of http cache.
597 URLRequestContextConfig::HttpCacheType::DISK,
598 // Max size of http cache in bytes.
599 1024000,
600 // Disable caching for HTTP responses. Other information may be stored in
601 // the cache.
602 false,
603 // Storage path for http cache and cookie storage.
604 "/data/data/org.chromium.net/app_cronet_test/test_storage",
605 // Accept-Language request header field.
606 "foreign-language",
607 // User-Agent request header field.
608 "fake agent",
609 // JSON encoded experimental options.
610 "{\"QUIC\":{\"goaway_sessions_on_ip_change\":false}}",
611 // MockCertVerifier to use for testing purposes.
612 std::unique_ptr<net::CertVerifier>(),
613 // Enable network quality estimator.
614 false,
615 // Enable Public Key Pinning bypass for local trust anchors.
Paul Jensen6a1ea3a2018-08-24 14:46:41616 true,
617 // Optional network thread priority.
618 base::Optional<double>());
Zhongyi Shiaa518c22018-06-15 04:37:36619
620 net::URLRequestContextBuilder builder;
621 net::NetLog net_log;
622 config.ConfigureURLRequestContextBuilder(&builder, &net_log);
623 // Set a ProxyConfigService to avoid DCHECK failure when building.
624 builder.set_proxy_config_service(
625 std::make_unique<net::ProxyConfigServiceFixed>(
626 net::ProxyConfigWithAnnotation::CreateDirect()));
627 std::unique_ptr<net::URLRequestContext> context(builder.Build());
628 const net::HttpNetworkSession::Params* params =
629 context->GetNetworkSessionParams();
630
631 EXPECT_FALSE(params->quic_close_sessions_on_ip_change);
632 EXPECT_FALSE(params->quic_goaway_sessions_on_ip_change);
633}
634
Yixin Wang10f477ed2017-11-21 04:20:20635TEST(URLRequestContextConfigTest, SetQuicConnectionMigrationV2Options) {
Zhongyi Shi64795622017-11-20 02:21:49636 base::test::ScopedTaskEnvironment scoped_task_environment_(
637 base::test::ScopedTaskEnvironment::MainThreadType::IO);
638
639 URLRequestContextConfig config(
640 // Enable QUIC.
641 true,
642 // QUIC User Agent ID.
643 "Default QUIC User Agent ID",
644 // Enable SPDY.
645 true,
646 // Enable Brotli.
647 false,
648 // Type of http cache.
649 URLRequestContextConfig::HttpCacheType::DISK,
650 // Max size of http cache in bytes.
651 1024000,
652 // Disable caching for HTTP responses. Other information may be stored in
653 // the cache.
654 false,
655 // Storage path for http cache and cookie storage.
656 "/data/data/org.chromium.net/app_cronet_test/test_storage",
Misha Efimovd4ab38302018-01-30 23:56:42657 // Accept-Language request header field.
658 "foreign-language",
Zhongyi Shi64795622017-11-20 02:21:49659 // User-Agent request header field.
660 "fake agent",
661 // JSON encoded experimental options.
Zhongyi Shif4683a32017-12-01 00:03:28662 "{\"QUIC\":{\"migrate_sessions_on_network_change_v2\":true,"
Zhongyi Shi73f23ca872017-12-13 18:37:13663 "\"migrate_sessions_early_v2\":true,"
Zhongyi Shiff359581bc2018-09-26 18:11:48664 "\"retry_on_alternate_network_before_handshake\":true,"
Zhongyi Shi32fe14d42019-02-28 00:25:36665 "\"migrate_idle_sessions\":true,"
Zhongyi Shie01f2db2019-02-22 19:53:23666 "\"retransmittable_on_wire_timeout_milliseconds\":1000,"
Zhongyi Shibc85e3e2019-02-12 19:34:42667 "\"idle_session_migration_period_seconds\":15,"
Zhongyi Shi8b1e43f2017-12-13 20:46:30668 "\"max_time_on_non_default_network_seconds\":10,"
Zhongyi Shiee760762018-08-01 00:54:29669 "\"max_migrations_to_non_default_network_on_write_error\":3,"
Zhongyi Shi8b1e43f2017-12-13 20:46:30670 "\"max_migrations_to_non_default_network_on_path_degrading\":4}}",
Zhongyi Shi64795622017-11-20 02:21:49671 // MockCertVerifier to use for testing purposes.
672 std::unique_ptr<net::CertVerifier>(),
673 // Enable network quality estimator.
674 false,
675 // Enable Public Key Pinning bypass for local trust anchors.
Paul Jensen6a1ea3a2018-08-24 14:46:41676 true,
677 // Optional network thread priority.
678 base::Optional<double>());
Zhongyi Shi64795622017-11-20 02:21:49679
680 net::URLRequestContextBuilder builder;
681 net::NetLog net_log;
682 config.ConfigureURLRequestContextBuilder(&builder, &net_log);
683 // Set a ProxyConfigService to avoid DCHECK failure when building.
684 builder.set_proxy_config_service(
Lily Houghtonef028852017-12-06 20:52:30685 std::make_unique<net::ProxyConfigServiceFixed>(
Ramin Halavatica8d5252018-03-12 05:33:49686 net::ProxyConfigWithAnnotation::CreateDirect()));
Zhongyi Shi64795622017-11-20 02:21:49687 std::unique_ptr<net::URLRequestContext> context(builder.Build());
688 const net::HttpNetworkSession::Params* params =
689 context->GetNetworkSessionParams();
690
691 EXPECT_TRUE(params->quic_migrate_sessions_on_network_change_v2);
Zhongyi Shif4683a32017-12-01 00:03:28692 EXPECT_TRUE(params->quic_migrate_sessions_early_v2);
Zhongyi Shiff359581bc2018-09-26 18:11:48693 EXPECT_TRUE(params->quic_retry_on_alternate_network_before_handshake);
Zhongyi Shie01f2db2019-02-22 19:53:23694 EXPECT_EQ(1000, params->quic_retransmittable_on_wire_timeout_milliseconds);
Zhongyi Shi32fe14d42019-02-28 00:25:36695 EXPECT_TRUE(params->quic_migrate_idle_sessions);
Zhongyi Shibc85e3e2019-02-12 19:34:42696 EXPECT_EQ(base::TimeDelta::FromSeconds(15),
697 params->quic_idle_session_migration_period);
Zhongyi Shi73f23ca872017-12-13 18:37:13698 EXPECT_EQ(base::TimeDelta::FromSeconds(10),
699 params->quic_max_time_on_non_default_network);
Zhongyi Shiee760762018-08-01 00:54:29700 EXPECT_EQ(3,
701 params->quic_max_migrations_to_non_default_network_on_write_error);
Zhongyi Shi8b1e43f2017-12-13 20:46:30702 EXPECT_EQ(
703 4, params->quic_max_migrations_to_non_default_network_on_path_degrading);
Zhongyi Shi64795622017-11-20 02:21:49704}
705
Renjie94b90712018-10-18 21:03:19706TEST(URLRequestContextConfigTest, SetQuicStaleDNSracing) {
707 base::test::ScopedTaskEnvironment scoped_task_environment_(
708 base::test::ScopedTaskEnvironment::MainThreadType::IO);
709
710 URLRequestContextConfig config(
711 // Enable QUIC.
712 true,
713 // QUIC User Agent ID.
714 "Default QUIC User Agent ID",
715 // Enable SPDY.
716 true,
717 // Enable Brotli.
718 false,
719 // Type of http cache.
720 URLRequestContextConfig::HttpCacheType::DISK,
721 // Max size of http cache in bytes.
722 1024000,
723 // Disable caching for HTTP responses. Other information may be stored in
724 // the cache.
725 false,
726 // Storage path for http cache and cookie storage.
727 "/data/data/org.chromium.net/app_cronet_test/test_storage",
728 // Accept-Language request header field.
729 "foreign-language",
730 // User-Agent request header field.
731 "fake agent",
732 // JSON encoded experimental options.
733 "{\"QUIC\":{\"race_stale_dns_on_connection\":true}}",
734 // MockCertVerifier to use for testing purposes.
735 std::unique_ptr<net::CertVerifier>(),
736 // Enable network quality estimator.
737 false,
738 // Enable Public Key Pinning bypass for local trust anchors.
739 true,
740 // Optional network thread priority.
741 base::Optional<double>());
742
743 net::URLRequestContextBuilder builder;
744 net::NetLog net_log;
745 config.ConfigureURLRequestContextBuilder(&builder, &net_log);
746 // Set a ProxyConfigService to avoid DCHECK failure when building.
747 builder.set_proxy_config_service(
748 std::make_unique<net::ProxyConfigServiceFixed>(
749 net::ProxyConfigWithAnnotation::CreateDirect()));
750 std::unique_ptr<net::URLRequestContext> context(builder.Build());
751 const net::HttpNetworkSession::Params* params =
752 context->GetNetworkSessionParams();
753
754 EXPECT_TRUE(params->quic_race_stale_dns_on_connection);
755}
756
Yixin Wang10f477ed2017-11-21 04:20:20757TEST(URLRequestContextConfigTest, SetQuicHostWhitelist) {
758 base::test::ScopedTaskEnvironment scoped_task_environment_(
759 base::test::ScopedTaskEnvironment::MainThreadType::IO);
760
761 URLRequestContextConfig config(
762 // Enable QUIC.
763 true,
764 // QUIC User Agent ID.
765 "Default QUIC User Agent ID",
766 // Enable SPDY.
767 true,
768 // Enable Brotli.
769 false,
770 // Type of http cache.
771 URLRequestContextConfig::HttpCacheType::DISK,
772 // Max size of http cache in bytes.
773 1024000,
774 // Disable caching for HTTP responses. Other information may be stored in
775 // the cache.
776 false,
777 // Storage path for http cache and cookie storage.
778 "/data/data/org.chromium.net/app_cronet_test/test_storage",
Misha Efimovd4ab38302018-01-30 23:56:42779 // Accept-Language request header field.
780 "foreign-language",
Yixin Wang10f477ed2017-11-21 04:20:20781 // User-Agent request header field.
782 "fake agent",
783 // JSON encoded experimental options.
784 "{\"QUIC\":{\"host_whitelist\":\"www.example.com,www.example.org\"}}",
785 // MockCertVerifier to use for testing purposes.
786 std::unique_ptr<net::CertVerifier>(),
787 // Enable network quality estimator.
788 false,
789 // Enable Public Key Pinning bypass for local trust anchors.
Paul Jensen6a1ea3a2018-08-24 14:46:41790 true,
791 // Optional network thread priority.
792 base::Optional<double>());
Yixin Wang10f477ed2017-11-21 04:20:20793
794 net::URLRequestContextBuilder builder;
795 net::NetLog net_log;
796 config.ConfigureURLRequestContextBuilder(&builder, &net_log);
797 // Set a ProxyConfigService to avoid DCHECK failure when building.
798 builder.set_proxy_config_service(
Lily Houghtonef028852017-12-06 20:52:30799 std::make_unique<net::ProxyConfigServiceFixed>(
Ramin Halavatica8d5252018-03-12 05:33:49800 net::ProxyConfigWithAnnotation::CreateDirect()));
Yixin Wang10f477ed2017-11-21 04:20:20801 std::unique_ptr<net::URLRequestContext> context(builder.Build());
802 const net::HttpNetworkSession::Params* params =
803 context->GetNetworkSessionParams();
804
805 EXPECT_TRUE(
806 base::ContainsKey(params->quic_host_whitelist, "www.example.com"));
807 EXPECT_TRUE(
808 base::ContainsKey(params->quic_host_whitelist, "www.example.org"));
809}
810
Yixin Wang983875152017-11-21 20:30:13811TEST(URLRequestContextConfigTest, SetQuicMaxTimeBeforeCryptoHandshake) {
812 base::test::ScopedTaskEnvironment scoped_task_environment_(
813 base::test::ScopedTaskEnvironment::MainThreadType::IO);
814
815 URLRequestContextConfig config(
816 // Enable QUIC.
817 true,
818 // QUIC User Agent ID.
819 "Default QUIC User Agent ID",
820 // Enable SPDY.
821 true,
822 // Enable Brotli.
823 false,
824 // Type of http cache.
825 URLRequestContextConfig::HttpCacheType::DISK,
826 // Max size of http cache in bytes.
827 1024000,
828 // Disable caching for HTTP responses. Other information may be stored in
829 // the cache.
830 false,
831 // Storage path for http cache and cookie storage.
832 "/data/data/org.chromium.net/app_cronet_test/test_storage",
Misha Efimovd4ab38302018-01-30 23:56:42833 // Accept-Language request header field.
834 "foreign-language",
Yixin Wang983875152017-11-21 20:30:13835 // User-Agent request header field.
836 "fake agent",
837 // JSON encoded experimental options.
838 "{\"QUIC\":{\"max_time_before_crypto_handshake_seconds\":7,"
839 "\"max_idle_time_before_crypto_handshake_seconds\":11}}",
840 // MockCertVerifier to use for testing purposes.
841 std::unique_ptr<net::CertVerifier>(),
842 // Enable network quality estimator.
843 false,
844 // Enable Public Key Pinning bypass for local trust anchors.
Paul Jensen6a1ea3a2018-08-24 14:46:41845 true,
846 // Optional network thread priority.
847 base::Optional<double>());
Yixin Wang983875152017-11-21 20:30:13848
849 net::URLRequestContextBuilder builder;
850 net::NetLog net_log;
851 config.ConfigureURLRequestContextBuilder(&builder, &net_log);
852 // Set a ProxyConfigService to avoid DCHECK failure when building.
853 builder.set_proxy_config_service(
Lily Houghtonef028852017-12-06 20:52:30854 std::make_unique<net::ProxyConfigServiceFixed>(
Ramin Halavatica8d5252018-03-12 05:33:49855 net::ProxyConfigWithAnnotation::CreateDirect()));
Yixin Wang983875152017-11-21 20:30:13856 std::unique_ptr<net::URLRequestContext> context(builder.Build());
857 const net::HttpNetworkSession::Params* params =
858 context->GetNetworkSessionParams();
859
860 EXPECT_EQ(7, params->quic_max_time_before_crypto_handshake_seconds);
861 EXPECT_EQ(11, params->quic_max_idle_time_before_crypto_handshake_seconds);
862}
863
Yixin Wang1875fdb2017-12-06 02:26:49864TEST(URLURLRequestContextConfigTest, SetQuicConnectionOptions) {
865 base::test::ScopedTaskEnvironment scoped_task_environment_(
866 base::test::ScopedTaskEnvironment::MainThreadType::IO);
867
868 URLRequestContextConfig config(
869 // Enable QUIC.
870 true,
871 // QUIC User Agent ID.
872 "Default QUIC User Agent ID",
873 // Enable SPDY.
874 true,
875 // Enable Brotli.
876 false,
877 // Type of http cache.
878 URLRequestContextConfig::HttpCacheType::DISK,
879 // Max size of http cache in bytes.
880 1024000,
881 // Disable caching for HTTP responses. Other information may be stored in
882 // the cache.
883 false,
884 // Storage path for http cache and cookie storage.
885 "/data/data/org.chromium.net/app_cronet_test/test_storage",
Misha Efimovd4ab38302018-01-30 23:56:42886 // Accept-Language request header field.
887 "foreign-language",
Yixin Wang1875fdb2017-12-06 02:26:49888 // User-Agent request header field.
889 "fake agent",
890 // JSON encoded experimental options.
891 "{\"QUIC\":{\"connection_options\":\"TIME,TBBR,REJ\","
892 "\"client_connection_options\":\"TBBR,1RTT\"}}",
893 // MockCertVerifier to use for testing purposes.
894 std::unique_ptr<net::CertVerifier>(),
895 // Enable network quality estimator.
896 false,
897 // Enable Public Key Pinning bypass for local trust anchors.
Paul Jensen6a1ea3a2018-08-24 14:46:41898 true,
899 // Optional network thread priority.
900 base::Optional<double>());
Yixin Wang1875fdb2017-12-06 02:26:49901
902 net::URLRequestContextBuilder builder;
903 net::NetLog net_log;
904 config.ConfigureURLRequestContextBuilder(&builder, &net_log);
905 // Set a ProxyConfigService to avoid DCHECK failure when building.
906 builder.set_proxy_config_service(
Gyuyoung Kim6afb5082018-01-19 13:35:57907 std::make_unique<net::ProxyConfigServiceFixed>(
Ramin Halavatica8d5252018-03-12 05:33:49908 net::ProxyConfigWithAnnotation::CreateDirect()));
Yixin Wang1875fdb2017-12-06 02:26:49909 std::unique_ptr<net::URLRequestContext> context(builder.Build());
910 const net::HttpNetworkSession::Params* params =
911 context->GetNetworkSessionParams();
912
Ryan Hamilton8d9ee76e2018-05-29 23:52:52913 quic::QuicTagVector connection_options;
914 connection_options.push_back(quic::kTIME);
915 connection_options.push_back(quic::kTBBR);
916 connection_options.push_back(quic::kREJ);
Yixin Wang1875fdb2017-12-06 02:26:49917 EXPECT_EQ(connection_options, params->quic_connection_options);
918
Ryan Hamilton8d9ee76e2018-05-29 23:52:52919 quic::QuicTagVector client_connection_options;
920 client_connection_options.push_back(quic::kTBBR);
921 client_connection_options.push_back(quic::k1RTT);
Yixin Wang1875fdb2017-12-06 02:26:49922 EXPECT_EQ(client_connection_options, params->quic_client_connection_options);
923}
924
Misha Efimovd4ab38302018-01-30 23:56:42925TEST(URLURLRequestContextConfigTest, SetAcceptLanguageAndUserAgent) {
926 base::test::ScopedTaskEnvironment scoped_task_environment_(
927 base::test::ScopedTaskEnvironment::MainThreadType::IO);
928
929 URLRequestContextConfig config(
930 // Enable QUIC.
931 true,
932 // QUIC User Agent ID.
933 "Default QUIC User Agent ID",
934 // Enable SPDY.
935 true,
936 // Enable Brotli.
937 false,
938 // Type of http cache.
939 URLRequestContextConfig::HttpCacheType::DISK,
940 // Max size of http cache in bytes.
941 1024000,
942 // Disable caching for HTTP responses. Other information may be stored in
943 // the cache.
944 false,
945 // Storage path for http cache and cookie storage.
946 "/data/data/org.chromium.net/app_cronet_test/test_storage",
947 // Accept-Language request header field.
948 "foreign-language",
949 // User-Agent request header field.
950 "fake agent",
951 // JSON encoded experimental options.
952 "{}",
953 // MockCertVerifier to use for testing purposes.
954 std::unique_ptr<net::CertVerifier>(),
955 // Enable network quality estimator.
956 false,
957 // Enable Public Key Pinning bypass for local trust anchors.
Paul Jensen6a1ea3a2018-08-24 14:46:41958 true,
959 // Optional network thread priority.
960 base::Optional<double>());
Misha Efimovd4ab38302018-01-30 23:56:42961
962 net::URLRequestContextBuilder builder;
963 net::NetLog net_log;
964 config.ConfigureURLRequestContextBuilder(&builder, &net_log);
965 // Set a ProxyConfigService to avoid DCHECK failure when building.
966 builder.set_proxy_config_service(
967 std::make_unique<net::ProxyConfigServiceFixed>(
Ramin Halavatica8d5252018-03-12 05:33:49968 net::ProxyConfigWithAnnotation::CreateDirect()));
Misha Efimovd4ab38302018-01-30 23:56:42969 std::unique_ptr<net::URLRequestContext> context(builder.Build());
970 EXPECT_EQ("foreign-language",
971 context->http_user_agent_settings()->GetAcceptLanguage());
972 EXPECT_EQ("fake agent", context->http_user_agent_settings()->GetUserAgent());
973}
974
juliatuttle50d9c4b2016-08-23 22:49:19975// See stale_host_resolver_unittest.cc for test of StaleDNS options.
976
xunjielif24ee5f2015-11-23 18:05:26977} // namespace cronet