Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(447)

Side by Side Diff: net/http/http_response_headers_unittest.cc

Issue 1481143002: Added HttpUtils::HasValidators and HttpResponse::HasValidators (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Clarified the documentation Created 4 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « net/http/http_response_headers.cc ('k') | net/http/http_util.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include <stdint.h> 5 #include <stdint.h>
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <iostream> 8 #include <iostream>
9 #include <limits> 9 #include <limits>
10 10
(...skipping 1616 matching lines...) Expand 10 before | Expand all | Expand 10 after
1627 { "HTTP/1.1 200 OK\n" 1627 { "HTTP/1.1 200 OK\n"
1628 "etag: W / \"foo\"\n", 1628 "etag: W / \"foo\"\n",
1629 false 1629 false
1630 } 1630 }
1631 }; 1631 };
1632 1632
1633 INSTANTIATE_TEST_CASE_P(HttpResponseHeaders, 1633 INSTANTIATE_TEST_CASE_P(HttpResponseHeaders,
1634 HasStrongValidatorsTest, 1634 HasStrongValidatorsTest,
1635 testing::ValuesIn(strong_validators_tests)); 1635 testing::ValuesIn(strong_validators_tests));
1636 1636
1637 TEST(HttpResponseHeadersTest, HasValidatorsNone) {
1638 std::string headers("HTTP/1.1 200 OK");
1639 HeadersToRaw(&headers);
1640 scoped_refptr<HttpResponseHeaders> parsed(new HttpResponseHeaders(headers));
1641 EXPECT_FALSE(parsed->HasValidators());
1642 }
1643
1644 TEST(HttpResponseHeadersTest, HasValidatorsEtag) {
1645 std::string headers(
1646 "HTTP/1.1 200 OK\n"
1647 "etag: \"anything\"");
1648 HeadersToRaw(&headers);
1649 scoped_refptr<HttpResponseHeaders> parsed(new HttpResponseHeaders(headers));
1650 EXPECT_TRUE(parsed->HasValidators());
1651 }
1652
1653 TEST(HttpResponseHeadersTest, HasValidatorsLastModified) {
1654 std::string headers(
1655 "HTTP/1.1 200 OK\n"
1656 "Last-Modified: Wed, 28 Nov 2007 00:40:10 GMT");
1657 HeadersToRaw(&headers);
1658 scoped_refptr<HttpResponseHeaders> parsed(new HttpResponseHeaders(headers));
1659 EXPECT_TRUE(parsed->HasValidators());
1660 }
1661
1662 TEST(HttpResponseHeadersTest, HasValidatorsWeakEtag) {
1663 std::string headers(
1664 "HTTP/1.1 200 OK\n"
1665 "etag: W/\"anything\"");
1666 HeadersToRaw(&headers);
1667 scoped_refptr<HttpResponseHeaders> parsed(new HttpResponseHeaders(headers));
1668 EXPECT_TRUE(parsed->HasValidators());
1669 }
1670
1637 struct AddHeaderTestData { 1671 struct AddHeaderTestData {
1638 const char* orig_headers; 1672 const char* orig_headers;
1639 const char* new_header; 1673 const char* new_header;
1640 const char* expected_headers; 1674 const char* expected_headers;
1641 }; 1675 };
1642 1676
1643 class AddHeaderTest 1677 class AddHeaderTest
1644 : public HttpResponseHeadersTest, 1678 : public HttpResponseHeadersTest,
1645 public ::testing::WithParamInterface<AddHeaderTestData> { 1679 public ::testing::WithParamInterface<AddHeaderTestData> {
1646 }; 1680 };
(...skipping 467 matching lines...) Expand 10 before | Expand all | Expand 10 after
2114 TEST_F(HttpResponseHeadersCacheControlTest, 2148 TEST_F(HttpResponseHeadersCacheControlTest,
2115 FirstStaleWhileRevalidateValueUsed) { 2149 FirstStaleWhileRevalidateValueUsed) {
2116 InitializeHeadersWithCacheControl( 2150 InitializeHeadersWithCacheControl(
2117 "stale-while-revalidate=1,stale-while-revalidate=7200"); 2151 "stale-while-revalidate=1,stale-while-revalidate=7200");
2118 EXPECT_EQ(TimeDelta::FromSeconds(1), GetStaleWhileRevalidateValue()); 2152 EXPECT_EQ(TimeDelta::FromSeconds(1), GetStaleWhileRevalidateValue());
2119 } 2153 }
2120 2154
2121 } // namespace 2155 } // namespace
2122 2156
2123 } // namespace net 2157 } // namespace net
OLDNEW
« no previous file with comments | « net/http/http_response_headers.cc ('k') | net/http/http_util.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698