summaryrefslogtreecommitdiffstats
path: root/net/http/http_vary_data_unittest.cc
diff options
context:
space:
mode:
authorericroman@google.com <ericroman@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2009-03-21 03:46:06 +0000
committerericroman@google.com <ericroman@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2009-03-21 03:46:06 +0000
commit89ceba9a484f853964e5504f14927a8cf7e72449 (patch)
tree5db8fb2d7cebebc53b107db44f521f078b66cf62 /net/http/http_vary_data_unittest.cc
parentd0ee935a4bdb1d111a4584ec4c0a03287bc43cd4 (diff)
downloadchromium_src-89ceba9a484f853964e5504f14927a8cf7e72449.zip
chromium_src-89ceba9a484f853964e5504f14927a8cf7e72449.tar.gz
chromium_src-89ceba9a484f853964e5504f14927a8cf7e72449.tar.bz2
Fully reset HttpNetworkTransaction::response_ when restarting the transaction. The reset is done using the default constructor.
This is less fragile than resetting each member manually, and in fact not all members were being reset (for example, vary_data and ssl_info). In the case of vary_data this could cause a subtle glitch, since calling HttpVaryData::Init() twice on the same object doesn't fully re-initialize. The changes outside of http_network_transaction.cc are just a safety net -- it seemed reasonable to make HttpVaryData::Init() support the multiple-init model. Review URL: http://codereview.chromium.org/50031 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@12243 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net/http/http_vary_data_unittest.cc')
-rw-r--r--net/http/http_vary_data_unittest.cc19
1 files changed, 18 insertions, 1 deletions
diff --git a/net/http/http_vary_data_unittest.cc b/net/http/http_vary_data_unittest.cc
index 852d7d4..7b2bd16 100644
--- a/net/http/http_vary_data_unittest.cc
+++ b/net/http/http_vary_data_unittest.cc
@@ -29,7 +29,7 @@ struct TestTransaction {
} // namespace
-TEST(HttpVaryDataTest, IsValid) {
+TEST(HttpVaryDataTest, IsInvalid) {
// All of these responses should result in an invalid vary data object.
const char* kTestResponses[] = {
"HTTP/1.1 200 OK\n\n",
@@ -43,11 +43,28 @@ TEST(HttpVaryDataTest, IsValid) {
t.Init("", kTestResponses[i]);
net::HttpVaryData v;
+ EXPECT_FALSE(v.is_valid());
EXPECT_FALSE(v.Init(t.request, *t.response));
EXPECT_FALSE(v.is_valid());
}
}
+TEST(HttpVaryDataTest, MultipleInit) {
+ net::HttpVaryData v;
+
+ // Init to something valid.
+ TestTransaction t1;
+ t1.Init("Foo: 1\nbar: 23", "HTTP/1.1 200 OK\nVary: foo, bar\n\n");
+ EXPECT_TRUE(v.Init(t1.request, *t1.response));
+ EXPECT_TRUE(v.is_valid());
+
+ // Now overwrite by initializing to something invalid.
+ TestTransaction t2;
+ t2.Init("Foo: 1\nbar: 23", "HTTP/1.1 200 OK\nVary: *\n\n");
+ EXPECT_FALSE(v.Init(t2.request, *t2.response));
+ EXPECT_FALSE(v.is_valid());
+}
+
TEST(HttpVaryDataTest, DoesVary) {
TestTransaction a;
a.Init("Foo: 1", "HTTP/1.1 200 OK\nVary: foo\n\n");