| Index: net/url_request/url_request_quic_unittest.cc
|
| diff --git a/net/url_request/url_request_quic_unittest.cc b/net/url_request/url_request_quic_unittest.cc
|
| index f435d61cdf19d8a52a3461fe1de2828859dc3901..7532196988f52ad3238b3bdcf438f345d128083f 100644
|
| --- a/net/url_request/url_request_quic_unittest.cc
|
| +++ b/net/url_request/url_request_quic_unittest.cc
|
| @@ -15,17 +15,12 @@
|
| #include "net/cert/mock_cert_verifier.h"
|
| #include "net/dns/mapped_host_resolver.h"
|
| #include "net/dns/mock_host_resolver.h"
|
| -#include "net/log/net_log_event_type.h"
|
| -#include "net/log/test_net_log.h"
|
| -#include "net/log/test_net_log_entry.h"
|
| #include "net/quic/chromium/crypto/proof_source_chromium.h"
|
| #include "net/quic/test_tools/crypto_test_utils.h"
|
| #include "net/test/cert_test_util.h"
|
| #include "net/test/gtest_util.h"
|
| #include "net/test/test_data_directory.h"
|
| -#include "net/tools/quic/quic_dispatcher.h"
|
| #include "net/tools/quic/quic_http_response_cache.h"
|
| -#include "net/tools/quic/quic_simple_dispatcher.h"
|
| #include "net/tools/quic/quic_simple_server.h"
|
| #include "net/url_request/url_request.h"
|
| #include "net/url_request/url_request_test_util.h"
|
| @@ -69,11 +64,9 @@
|
| params->origins_to_force_quic_on.insert(HostPortPair(kTestServerHost, 443));
|
| params->cert_verifier = &cert_verifier_;
|
| params->enable_quic = true;
|
| - params->enable_server_push_cancellation = true;
|
| context_->set_host_resolver(host_resolver_.get());
|
| context_->set_http_network_session_params(std::move(params));
|
| context_->set_cert_verifier(&cert_verifier_);
|
| - context_->set_net_log(&net_log_);
|
| }
|
|
|
| void TearDown() override {
|
| @@ -93,23 +86,6 @@
|
| RequestPriority priority,
|
| URLRequest::Delegate* delegate) {
|
| return context_->CreateRequest(url, priority, delegate);
|
| - }
|
| -
|
| - void ExtractNetLog(NetLogEventType type,
|
| - TestNetLogEntry::List* entry_list) const {
|
| - net::TestNetLogEntry::List entries;
|
| - net_log_.GetEntries(&entries);
|
| -
|
| - for (const auto& entry : entries) {
|
| - if (entry.type == type)
|
| - entry_list->push_back(entry);
|
| - }
|
| - }
|
| -
|
| - unsigned int GetRstErrorCountReceivedByServer(
|
| - QuicRstStreamErrorCode error_code) const {
|
| - return (static_cast<QuicSimpleDispatcher*>(server_->dispatcher()))
|
| - ->GetRstErrorCount(error_code);
|
| }
|
|
|
| private:
|
| @@ -117,7 +93,6 @@
|
| // Set up in-memory cache.
|
| response_cache_.AddSimpleResponse(kTestServerHost, kHelloPath, kHelloStatus,
|
| kHelloBodyValue);
|
| - response_cache_.InitializeFromDirectory(ServerPushCacheDirectory());
|
| net::QuicConfig config;
|
| // Set up server certs.
|
| std::unique_ptr<net::ProofSourceChromium> proof_source(
|
| @@ -145,19 +120,9 @@
|
| EXPECT_TRUE(host_resolver_->AddRuleFromString(map_rule));
|
| }
|
|
|
| - std::string ServerPushCacheDirectory() {
|
| - base::FilePath path;
|
| - PathService::Get(base::DIR_SOURCE_ROOT, &path);
|
| - path = path.AppendASCII("net").AppendASCII("data").AppendASCII(
|
| - "quic_http_response_cache_data_with_push");
|
| - // The file path is known to be an ascii string.
|
| - return path.MaybeAsASCII();
|
| - }
|
| -
|
| std::unique_ptr<MappedHostResolver> host_resolver_;
|
| std::unique_ptr<QuicSimpleServer> server_;
|
| std::unique_ptr<TestURLRequestContext> context_;
|
| - TestNetLog net_log_;
|
| QuicHttpResponseCache response_cache_;
|
| MockCertVerifier cert_verifier_;
|
| };
|
| @@ -244,201 +209,6 @@
|
|
|
| EXPECT_TRUE(request->status().is_success());
|
| EXPECT_EQ(kHelloBodyValue, delegate.data_received());
|
| -}
|
| -
|
| -TEST_F(URLRequestQuicTest, CancelPushIfCached) {
|
| - base::RunLoop run_loop;
|
| - WaitForCompletionNetworkDelegate network_delegate(
|
| - run_loop.QuitClosure(), /*num_expected_requests=*/2);
|
| - SetNetworkDelegate(&network_delegate);
|
| -
|
| - Init();
|
| - {
|
| - // Send a request to the pushed url: /kitten-1.jpg to pull the resource into
|
| - // cache.
|
| - CheckLoadTimingDelegate delegate(false);
|
| - std::string url =
|
| - base::StringPrintf("https://%s%s", kTestServerHost, "/kitten-1.jpg");
|
| - std::unique_ptr<URLRequest> request =
|
| - CreateRequest(GURL(url), DEFAULT_PRIORITY, &delegate);
|
| -
|
| - request->Start();
|
| - ASSERT_TRUE(request->is_pending());
|
| - base::RunLoop().Run();
|
| -
|
| - EXPECT_TRUE(request->status().is_success());
|
| - }
|
| -
|
| - // Send a request to /index2.html which pushes /kitten-1.jpg and /favicon.ico.
|
| - // Should cancel push for /kitten-1.jpg.
|
| - CheckLoadTimingDelegate delegate(true);
|
| - std::string url =
|
| - base::StringPrintf("https://%s%s", kTestServerHost, "/index2.html");
|
| - std::unique_ptr<URLRequest> request =
|
| - CreateRequest(GURL(url), DEFAULT_PRIORITY, &delegate);
|
| -
|
| - request->Start();
|
| - ASSERT_TRUE(request->is_pending());
|
| - base::RunLoop().Run();
|
| -
|
| - // Extract net logs on client side to verify push lookup transactions.
|
| - net::TestNetLogEntry::List entries;
|
| - ExtractNetLog(NetLogEventType::SERVER_PUSH_LOOKUP_TRANSACTION, &entries);
|
| -
|
| - EXPECT_EQ(4u, entries.size());
|
| -
|
| - std::string value;
|
| - int net_error;
|
| - std::string push_url_1 =
|
| - base::StringPrintf("https://%s%s", kTestServerHost, "/kitten-1.jpg");
|
| - std::string push_url_2 =
|
| - base::StringPrintf("https://%s%s", kTestServerHost, "/favicon.ico");
|
| -
|
| - EXPECT_TRUE(entries[0].GetStringValue("push_url", &value));
|
| - EXPECT_EQ(value, push_url_1);
|
| - // No net error code for this lookup transaction, the push is found.
|
| - EXPECT_FALSE(entries[1].GetIntegerValue("net_error", &net_error));
|
| -
|
| - EXPECT_TRUE(entries[2].GetStringValue("push_url", &value));
|
| - EXPECT_EQ(value, push_url_2);
|
| - // Net error code -400 is found for this lookup transaction, the push is not
|
| - // found in the cache.
|
| - EXPECT_TRUE(entries[3].GetIntegerValue("net_error", &net_error));
|
| - EXPECT_EQ(net_error, -400);
|
| -
|
| - EXPECT_TRUE(request->status().is_success());
|
| -
|
| - // Verify the reset error count received on the server side.
|
| - EXPECT_EQ(1u, GetRstErrorCountReceivedByServer(QUIC_STREAM_CANCELLED));
|
| -}
|
| -
|
| -TEST_F(URLRequestQuicTest, CancelPushIfCached2) {
|
| - base::RunLoop run_loop;
|
| - WaitForCompletionNetworkDelegate network_delegate(
|
| - run_loop.QuitClosure(), /*num_expected_requests=*/3);
|
| - SetNetworkDelegate(&network_delegate);
|
| -
|
| - Init();
|
| - {
|
| - // Send a request to the pushed url: /kitten-1.jpg to pull the resource into
|
| - // cache.
|
| - CheckLoadTimingDelegate delegate(false);
|
| - std::string url =
|
| - base::StringPrintf("https://%s%s", kTestServerHost, "/kitten-1.jpg");
|
| - std::unique_ptr<URLRequest> request =
|
| - CreateRequest(GURL(url), DEFAULT_PRIORITY, &delegate);
|
| -
|
| - request->Start();
|
| - ASSERT_TRUE(request->is_pending());
|
| - base::RunLoop().Run();
|
| -
|
| - EXPECT_TRUE(request->status().is_success());
|
| - EXPECT_NE(network_delegate.total_network_bytes_sent(), 0u);
|
| - }
|
| -
|
| - {
|
| - // Send a request to the pushed url: /favicon.ico to pull the resource into
|
| - // cache.
|
| - CheckLoadTimingDelegate delegate(true);
|
| - std::string url =
|
| - base::StringPrintf("https://%s%s", kTestServerHost, "/favicon.ico");
|
| - std::unique_ptr<URLRequest> request =
|
| - CreateRequest(GURL(url), DEFAULT_PRIORITY, &delegate);
|
| -
|
| - request->Start();
|
| - ASSERT_TRUE(request->is_pending());
|
| - base::RunLoop().Run();
|
| -
|
| - EXPECT_TRUE(request->status().is_success());
|
| - }
|
| -
|
| - // Send a request to /index2.html which pushes /kitten-1.jpg and /favicon.ico.
|
| - // Should cancel push for /kitten-1.jpg.
|
| - CheckLoadTimingDelegate delegate(true);
|
| - std::string url =
|
| - base::StringPrintf("https://%s%s", kTestServerHost, "/index2.html");
|
| - std::unique_ptr<URLRequest> request =
|
| - CreateRequest(GURL(url), DEFAULT_PRIORITY, &delegate);
|
| -
|
| - request->Start();
|
| - ASSERT_TRUE(request->is_pending());
|
| - base::RunLoop().Run();
|
| -
|
| - // Extract net logs on client side to verify push lookup transactions.
|
| - net::TestNetLogEntry::List entries;
|
| - ExtractNetLog(NetLogEventType::SERVER_PUSH_LOOKUP_TRANSACTION, &entries);
|
| -
|
| - EXPECT_EQ(4u, entries.size());
|
| -
|
| - std::string value;
|
| - int net_error;
|
| - std::string push_url_1 =
|
| - base::StringPrintf("https://%s%s", kTestServerHost, "/kitten-1.jpg");
|
| - std::string push_url_2 =
|
| - base::StringPrintf("https://%s%s", kTestServerHost, "/favicon.ico");
|
| -
|
| - EXPECT_TRUE(entries[0].GetStringValue("push_url", &value));
|
| - EXPECT_EQ(value, push_url_1);
|
| - // No net error code for this lookup transaction, the push is found.
|
| - EXPECT_FALSE(entries[1].GetIntegerValue("net_error", &net_error));
|
| -
|
| - EXPECT_TRUE(entries[2].GetStringValue("push_url", &value));
|
| - EXPECT_EQ(value, push_url_2);
|
| - // No net error code for this lookup transaction, the push is found.
|
| - EXPECT_FALSE(entries[3].GetIntegerValue("net_error", &net_error));
|
| -
|
| - EXPECT_TRUE(request->status().is_success());
|
| -
|
| - // Verify the reset error count received on the server side.
|
| - EXPECT_EQ(2u, GetRstErrorCountReceivedByServer(QUIC_STREAM_CANCELLED));
|
| -}
|
| -
|
| -TEST_F(URLRequestQuicTest, DoNotCancelPushIfNotFoundInCache) {
|
| - base::RunLoop run_loop;
|
| - WaitForCompletionNetworkDelegate network_delegate(
|
| - run_loop.QuitClosure(), /*num_expected_requests=*/1);
|
| - SetNetworkDelegate(&network_delegate);
|
| -
|
| - Init();
|
| - // Send a request to /index2.hmtl which pushes /kitten-1.jpg and /favicon.ico
|
| - // and shouldn't cancel any since neither is in cache.
|
| - CheckLoadTimingDelegate delegate(false);
|
| - std::string url =
|
| - base::StringPrintf("https://%s%s", kTestServerHost, "/index2.html");
|
| - std::unique_ptr<URLRequest> request =
|
| - CreateRequest(GURL(url), DEFAULT_PRIORITY, &delegate);
|
| -
|
| - request->Start();
|
| - ASSERT_TRUE(request->is_pending());
|
| - base::RunLoop().Run();
|
| -
|
| - // Extract net logs on client side to verify push lookup transactions.
|
| - net::TestNetLogEntry::List entries;
|
| - ExtractNetLog(NetLogEventType::SERVER_PUSH_LOOKUP_TRANSACTION, &entries);
|
| -
|
| - EXPECT_EQ(4u, entries.size());
|
| -
|
| - std::string value;
|
| - int net_error;
|
| - std::string push_url_1 =
|
| - base::StringPrintf("https://%s%s", kTestServerHost, "/kitten-1.jpg");
|
| - std::string push_url_2 =
|
| - base::StringPrintf("https://%s%s", kTestServerHost, "/favicon.ico");
|
| -
|
| - EXPECT_TRUE(entries[0].GetStringValue("push_url", &value));
|
| - EXPECT_EQ(value, push_url_1);
|
| - EXPECT_TRUE(entries[1].GetIntegerValue("net_error", &net_error));
|
| - EXPECT_EQ(net_error, -400);
|
| -
|
| - EXPECT_TRUE(entries[2].GetStringValue("push_url", &value));
|
| - EXPECT_EQ(value, push_url_2);
|
| - EXPECT_TRUE(entries[3].GetIntegerValue("net_error", &net_error));
|
| - EXPECT_EQ(net_error, -400);
|
| -
|
| - EXPECT_TRUE(request->status().is_success());
|
| -
|
| - // Verify the reset error count received on the server side.
|
| - EXPECT_EQ(0u, GetRstErrorCountReceivedByServer(QUIC_STREAM_CANCELLED));
|
| }
|
|
|
| // Tests that if two requests use the same QUIC session, the second request
|
|
|