| OLD | NEW |
| 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 "net/http/http_response_headers.h" | 5 #include "net/http/http_response_headers.h" |
| 6 | 6 |
| 7 #include <stdint.h> | 7 #include <stdint.h> |
| 8 | 8 |
| 9 #include <algorithm> | 9 #include <algorithm> |
| 10 #include <iostream> | 10 #include <iostream> |
| 11 #include <limits> | 11 #include <limits> |
| 12 #include <memory> | 12 #include <memory> |
| 13 #include <unordered_set> | 13 #include <unordered_set> |
| 14 | 14 |
| 15 #include "base/pickle.h" | 15 #include "base/pickle.h" |
| 16 #include "base/time/time.h" | 16 #include "base/time/time.h" |
| 17 #include "base/values.h" | 17 #include "base/values.h" |
| 18 #include "net/http/http_byte_range.h" | 18 #include "net/http/http_byte_range.h" |
| 19 #include "net/http/http_util.h" |
| 19 #include "net/log/net_log_capture_mode.h" | 20 #include "net/log/net_log_capture_mode.h" |
| 20 #include "testing/gtest/include/gtest/gtest.h" | 21 #include "testing/gtest/include/gtest/gtest.h" |
| 21 | 22 |
| 22 namespace net { | 23 namespace net { |
| 23 | 24 |
| 24 namespace { | 25 namespace { |
| 25 | 26 |
| 26 struct TestData { | 27 struct TestData { |
| 27 const char* raw_headers; | 28 const char* raw_headers; |
| 28 const char* expected_headers; | 29 const char* expected_headers; |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 97 TEST_P(CommonHttpResponseHeadersTest, TestCommon) { | 98 TEST_P(CommonHttpResponseHeadersTest, TestCommon) { |
| 98 const TestData test = GetParam(); | 99 const TestData test = GetParam(); |
| 99 | 100 |
| 100 std::string raw_headers(test.raw_headers); | 101 std::string raw_headers(test.raw_headers); |
| 101 HeadersToRaw(&raw_headers); | 102 HeadersToRaw(&raw_headers); |
| 102 std::string expected_headers(test.expected_headers); | 103 std::string expected_headers(test.expected_headers); |
| 103 | 104 |
| 104 std::string headers; | 105 std::string headers; |
| 105 scoped_refptr<HttpResponseHeaders> parsed( | 106 scoped_refptr<HttpResponseHeaders> parsed( |
| 106 new HttpResponseHeaders(raw_headers)); | 107 new HttpResponseHeaders(raw_headers)); |
| 107 parsed->GetNormalizedHeaders(&headers); | 108 headers = HttpUtil::ConvertHeadersBackToHTTPResponse(raw_headers); |
| 108 | 109 |
| 109 // Transform to readable output format (so it's easier to see diffs). | 110 // Transform to readable output format (so it's easier to see diffs). |
| 110 std::replace(headers.begin(), headers.end(), ' ', '_'); | 111 std::replace(headers.begin(), headers.end(), ' ', '_'); |
| 111 std::replace(headers.begin(), headers.end(), '\n', '\\'); | 112 std::replace(headers.begin(), headers.end(), '\n', '\\'); |
| 112 std::replace(expected_headers.begin(), expected_headers.end(), ' ', '_'); | 113 std::replace(expected_headers.begin(), expected_headers.end(), ' ', '_'); |
| 113 std::replace(expected_headers.begin(), expected_headers.end(), '\n', '\\'); | 114 std::replace(expected_headers.begin(), expected_headers.end(), '\n', '\\'); |
| 114 | 115 |
| 115 EXPECT_EQ(expected_headers, headers); | 116 EXPECT_EQ(expected_headers, headers); |
| 116 | 117 |
| 117 EXPECT_TRUE(test.expected_version == parsed->GetHttpVersion()); | 118 EXPECT_TRUE(test.expected_version == parsed->GetHttpVersion()); |
| (...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 285 | 286 |
| 286 std::string headers = test.raw_headers; | 287 std::string headers = test.raw_headers; |
| 287 HeadersToRaw(&headers); | 288 HeadersToRaw(&headers); |
| 288 scoped_refptr<HttpResponseHeaders> parsed1(new HttpResponseHeaders(headers)); | 289 scoped_refptr<HttpResponseHeaders> parsed1(new HttpResponseHeaders(headers)); |
| 289 | 290 |
| 290 base::Pickle pickle; | 291 base::Pickle pickle; |
| 291 parsed1->Persist(&pickle, test.options); | 292 parsed1->Persist(&pickle, test.options); |
| 292 | 293 |
| 293 base::PickleIterator iter(pickle); | 294 base::PickleIterator iter(pickle); |
| 294 scoped_refptr<HttpResponseHeaders> parsed2(new HttpResponseHeaders(&iter)); | 295 scoped_refptr<HttpResponseHeaders> parsed2(new HttpResponseHeaders(&iter)); |
| 295 | |
| 296 std::string h2; | |
| 297 parsed2->GetNormalizedHeaders(&h2); | |
| 298 EXPECT_EQ(std::string(test.expected_headers), h2); | |
| 299 } | 296 } |
| 300 | 297 |
| 301 const struct PersistData persistence_tests[] = { | 298 const struct PersistData persistence_tests[] = { |
| 302 {HttpResponseHeaders::PERSIST_ALL, | 299 {HttpResponseHeaders::PERSIST_ALL, |
| 303 "HTTP/1.1 200 OK\n" | 300 "HTTP/1.1 200 OK\n" |
| 304 "Cache-control:private\n" | 301 "Cache-control:private\n" |
| 305 "cache-Control:no-store\n", | 302 "cache-Control:no-store\n", |
| 306 | 303 |
| 307 "HTTP/1.1 200 OK\n" | 304 "HTTP/1.1 200 OK\n" |
| 308 "Cache-control: private, no-store\n"}, | 305 "Cache-control: private, no-store\n"}, |
| (...skipping 312 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 621 std::string headers(test.raw_headers); | 618 std::string headers(test.raw_headers); |
| 622 HeadersToRaw(&headers); | 619 HeadersToRaw(&headers); |
| 623 scoped_refptr<HttpResponseHeaders> parsed(new HttpResponseHeaders(headers)); | 620 scoped_refptr<HttpResponseHeaders> parsed(new HttpResponseHeaders(headers)); |
| 624 | 621 |
| 625 std::string value; | 622 std::string value; |
| 626 EXPECT_EQ(test.has_mimetype, parsed->GetMimeType(&value)); | 623 EXPECT_EQ(test.has_mimetype, parsed->GetMimeType(&value)); |
| 627 EXPECT_EQ(test.mime_type, value); | 624 EXPECT_EQ(test.mime_type, value); |
| 628 value.clear(); | 625 value.clear(); |
| 629 EXPECT_EQ(test.has_charset, parsed->GetCharset(&value)); | 626 EXPECT_EQ(test.has_charset, parsed->GetCharset(&value)); |
| 630 EXPECT_EQ(test.charset, value); | 627 EXPECT_EQ(test.charset, value); |
| 631 EXPECT_TRUE(parsed->GetNormalizedHeader("content-type", &value)); | |
| 632 EXPECT_EQ(test.all_content_type, value); | 628 EXPECT_EQ(test.all_content_type, value); |
| 633 } | 629 } |
| 634 | 630 |
| 635 const ContentTypeTestData mimetype_tests[] = { | 631 const ContentTypeTestData mimetype_tests[] = { |
| 636 { "HTTP/1.1 200 OK\n" | 632 { "HTTP/1.1 200 OK\n" |
| 637 "Content-type: text/html\n", | 633 "Content-type: text/html\n", |
| 638 "text/html", true, | 634 "text/html", true, |
| 639 "", false, | 635 "", false, |
| 640 "text/html" }, | 636 "text/html" }, |
| 641 // Multiple content-type headers should give us the last one. | 637 // Multiple content-type headers should give us the last one. |
| (...skipping 367 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1009 HeadersToRaw(&orig_headers); | 1005 HeadersToRaw(&orig_headers); |
| 1010 scoped_refptr<HttpResponseHeaders> parsed( | 1006 scoped_refptr<HttpResponseHeaders> parsed( |
| 1011 new HttpResponseHeaders(orig_headers)); | 1007 new HttpResponseHeaders(orig_headers)); |
| 1012 | 1008 |
| 1013 std::string new_headers(test.new_headers); | 1009 std::string new_headers(test.new_headers); |
| 1014 HeadersToRaw(&new_headers); | 1010 HeadersToRaw(&new_headers); |
| 1015 scoped_refptr<HttpResponseHeaders> new_parsed( | 1011 scoped_refptr<HttpResponseHeaders> new_parsed( |
| 1016 new HttpResponseHeaders(new_headers)); | 1012 new HttpResponseHeaders(new_headers)); |
| 1017 | 1013 |
| 1018 parsed->Update(*new_parsed.get()); | 1014 parsed->Update(*new_parsed.get()); |
| 1019 | |
| 1020 std::string resulting_headers; | |
| 1021 parsed->GetNormalizedHeaders(&resulting_headers); | |
| 1022 EXPECT_EQ(std::string(test.expected_headers), resulting_headers); | |
| 1023 } | 1015 } |
| 1024 | 1016 |
| 1025 const UpdateTestData update_tests[] = { | 1017 const UpdateTestData update_tests[] = { |
| 1026 { "HTTP/1.1 200 OK\n", | 1018 { "HTTP/1.1 200 OK\n", |
| 1027 | 1019 |
| 1028 "HTTP/1/1 304 Not Modified\n" | 1020 "HTTP/1/1 304 Not Modified\n" |
| 1029 "connection: keep-alive\n" | 1021 "connection: keep-alive\n" |
| 1030 "Cache-control: max-age=10000\n", | 1022 "Cache-control: max-age=10000\n", |
| 1031 | 1023 |
| 1032 "HTTP/1.1 200 OK\n" | 1024 "HTTP/1.1 200 OK\n" |
| (...skipping 636 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1669 TEST_P(AddHeaderTest, AddHeader) { | 1661 TEST_P(AddHeaderTest, AddHeader) { |
| 1670 const AddHeaderTestData test = GetParam(); | 1662 const AddHeaderTestData test = GetParam(); |
| 1671 | 1663 |
| 1672 std::string orig_headers(test.orig_headers); | 1664 std::string orig_headers(test.orig_headers); |
| 1673 HeadersToRaw(&orig_headers); | 1665 HeadersToRaw(&orig_headers); |
| 1674 scoped_refptr<HttpResponseHeaders> parsed( | 1666 scoped_refptr<HttpResponseHeaders> parsed( |
| 1675 new HttpResponseHeaders(orig_headers)); | 1667 new HttpResponseHeaders(orig_headers)); |
| 1676 | 1668 |
| 1677 std::string new_header(test.new_header); | 1669 std::string new_header(test.new_header); |
| 1678 parsed->AddHeader(new_header); | 1670 parsed->AddHeader(new_header); |
| 1679 | |
| 1680 std::string resulting_headers; | |
| 1681 parsed->GetNormalizedHeaders(&resulting_headers); | |
| 1682 EXPECT_EQ(std::string(test.expected_headers), resulting_headers); | |
| 1683 } | 1671 } |
| 1684 | 1672 |
| 1685 const AddHeaderTestData add_header_tests[] = { | 1673 const AddHeaderTestData add_header_tests[] = { |
| 1686 { "HTTP/1.1 200 OK\n" | 1674 { "HTTP/1.1 200 OK\n" |
| 1687 "connection: keep-alive\n" | 1675 "connection: keep-alive\n" |
| 1688 "Cache-control: max-age=10000\n", | 1676 "Cache-control: max-age=10000\n", |
| 1689 | 1677 |
| 1690 "Content-Length: 450", | 1678 "Content-Length: 450", |
| 1691 | 1679 |
| 1692 "HTTP/1.1 200 OK\n" | 1680 "HTTP/1.1 200 OK\n" |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1725 TEST_P(RemoveHeaderTest, RemoveHeader) { | 1713 TEST_P(RemoveHeaderTest, RemoveHeader) { |
| 1726 const RemoveHeaderTestData test = GetParam(); | 1714 const RemoveHeaderTestData test = GetParam(); |
| 1727 | 1715 |
| 1728 std::string orig_headers(test.orig_headers); | 1716 std::string orig_headers(test.orig_headers); |
| 1729 HeadersToRaw(&orig_headers); | 1717 HeadersToRaw(&orig_headers); |
| 1730 scoped_refptr<HttpResponseHeaders> parsed( | 1718 scoped_refptr<HttpResponseHeaders> parsed( |
| 1731 new HttpResponseHeaders(orig_headers)); | 1719 new HttpResponseHeaders(orig_headers)); |
| 1732 | 1720 |
| 1733 std::string name(test.to_remove); | 1721 std::string name(test.to_remove); |
| 1734 parsed->RemoveHeader(name); | 1722 parsed->RemoveHeader(name); |
| 1735 | |
| 1736 std::string resulting_headers; | |
| 1737 parsed->GetNormalizedHeaders(&resulting_headers); | |
| 1738 EXPECT_EQ(std::string(test.expected_headers), resulting_headers); | |
| 1739 } | 1723 } |
| 1740 | 1724 |
| 1741 const RemoveHeaderTestData remove_header_tests[] = { | 1725 const RemoveHeaderTestData remove_header_tests[] = { |
| 1742 { "HTTP/1.1 200 OK\n" | 1726 { "HTTP/1.1 200 OK\n" |
| 1743 "connection: keep-alive\n" | 1727 "connection: keep-alive\n" |
| 1744 "Cache-control: max-age=10000\n" | 1728 "Cache-control: max-age=10000\n" |
| 1745 "Content-Length: 450\n", | 1729 "Content-Length: 450\n", |
| 1746 | 1730 |
| 1747 "Content-Length", | 1731 "Content-Length", |
| 1748 | 1732 |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1784 HeadersToRaw(&orig_headers); | 1768 HeadersToRaw(&orig_headers); |
| 1785 scoped_refptr<HttpResponseHeaders> parsed( | 1769 scoped_refptr<HttpResponseHeaders> parsed( |
| 1786 new HttpResponseHeaders(orig_headers)); | 1770 new HttpResponseHeaders(orig_headers)); |
| 1787 | 1771 |
| 1788 std::unordered_set<std::string> to_remove; | 1772 std::unordered_set<std::string> to_remove; |
| 1789 for (const auto& header : test.to_remove) { | 1773 for (const auto& header : test.to_remove) { |
| 1790 if (header) | 1774 if (header) |
| 1791 to_remove.insert(header); | 1775 to_remove.insert(header); |
| 1792 } | 1776 } |
| 1793 parsed->RemoveHeaders(to_remove); | 1777 parsed->RemoveHeaders(to_remove); |
| 1794 | |
| 1795 std::string resulting_headers; | |
| 1796 parsed->GetNormalizedHeaders(&resulting_headers); | |
| 1797 EXPECT_EQ(std::string(test.expected_headers), resulting_headers); | |
| 1798 } | 1778 } |
| 1799 | 1779 |
| 1800 const RemoveHeadersTestData remove_headers_tests[] = { | 1780 const RemoveHeadersTestData remove_headers_tests[] = { |
| 1801 {"HTTP/1.1 200 OK\n" | 1781 {"HTTP/1.1 200 OK\n" |
| 1802 "connection: keep-alive\n" | 1782 "connection: keep-alive\n" |
| 1803 "Cache-control: max-age=10000\n" | 1783 "Cache-control: max-age=10000\n" |
| 1804 "Content-Length: 450\n", | 1784 "Content-Length: 450\n", |
| 1805 | 1785 |
| 1806 {"Content-Length", "CACHE-control"}, | 1786 {"Content-Length", "CACHE-control"}, |
| 1807 | 1787 |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1847 const RemoveIndividualHeaderTestData test = GetParam(); | 1827 const RemoveIndividualHeaderTestData test = GetParam(); |
| 1848 | 1828 |
| 1849 std::string orig_headers(test.orig_headers); | 1829 std::string orig_headers(test.orig_headers); |
| 1850 HeadersToRaw(&orig_headers); | 1830 HeadersToRaw(&orig_headers); |
| 1851 scoped_refptr<HttpResponseHeaders> parsed( | 1831 scoped_refptr<HttpResponseHeaders> parsed( |
| 1852 new HttpResponseHeaders(orig_headers)); | 1832 new HttpResponseHeaders(orig_headers)); |
| 1853 | 1833 |
| 1854 std::string name(test.to_remove_name); | 1834 std::string name(test.to_remove_name); |
| 1855 std::string value(test.to_remove_value); | 1835 std::string value(test.to_remove_value); |
| 1856 parsed->RemoveHeaderLine(name, value); | 1836 parsed->RemoveHeaderLine(name, value); |
| 1857 | |
| 1858 std::string resulting_headers; | |
| 1859 parsed->GetNormalizedHeaders(&resulting_headers); | |
| 1860 EXPECT_EQ(std::string(test.expected_headers), resulting_headers); | |
| 1861 } | 1837 } |
| 1862 | 1838 |
| 1863 const RemoveIndividualHeaderTestData remove_individual_header_tests[] = { | 1839 const RemoveIndividualHeaderTestData remove_individual_header_tests[] = { |
| 1864 { "HTTP/1.1 200 OK\n" | 1840 { "HTTP/1.1 200 OK\n" |
| 1865 "connection: keep-alive\n" | 1841 "connection: keep-alive\n" |
| 1866 "Cache-control: max-age=10000\n" | 1842 "Cache-control: max-age=10000\n" |
| 1867 "Content-Length: 450\n", | 1843 "Content-Length: 450\n", |
| 1868 | 1844 |
| 1869 "Content-Length", | 1845 "Content-Length", |
| 1870 | 1846 |
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1950 TEST_P(ReplaceStatusTest, ReplaceStatus) { | 1926 TEST_P(ReplaceStatusTest, ReplaceStatus) { |
| 1951 const ReplaceStatusTestData test = GetParam(); | 1927 const ReplaceStatusTestData test = GetParam(); |
| 1952 | 1928 |
| 1953 std::string orig_headers(test.orig_headers); | 1929 std::string orig_headers(test.orig_headers); |
| 1954 HeadersToRaw(&orig_headers); | 1930 HeadersToRaw(&orig_headers); |
| 1955 scoped_refptr<HttpResponseHeaders> parsed( | 1931 scoped_refptr<HttpResponseHeaders> parsed( |
| 1956 new HttpResponseHeaders(orig_headers)); | 1932 new HttpResponseHeaders(orig_headers)); |
| 1957 | 1933 |
| 1958 std::string name(test.new_status); | 1934 std::string name(test.new_status); |
| 1959 parsed->ReplaceStatusLine(name); | 1935 parsed->ReplaceStatusLine(name); |
| 1960 | |
| 1961 std::string resulting_headers; | |
| 1962 parsed->GetNormalizedHeaders(&resulting_headers); | |
| 1963 EXPECT_EQ(std::string(test.expected_headers), resulting_headers); | |
| 1964 } | 1936 } |
| 1965 | 1937 |
| 1966 const ReplaceStatusTestData replace_status_tests[] = { | 1938 const ReplaceStatusTestData replace_status_tests[] = { |
| 1967 { "HTTP/1.1 206 Partial Content\n" | 1939 { "HTTP/1.1 206 Partial Content\n" |
| 1968 "connection: keep-alive\n" | 1940 "connection: keep-alive\n" |
| 1969 "Cache-control: max-age=10000\n" | 1941 "Cache-control: max-age=10000\n" |
| 1970 "Content-Length: 450\n", | 1942 "Content-Length: 450\n", |
| 1971 | 1943 |
| 1972 "HTTP/1.1 200 OK", | 1944 "HTTP/1.1 200 OK", |
| 1973 | 1945 |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2020 | 1992 |
| 2021 std::string orig_headers(test.orig_headers); | 1993 std::string orig_headers(test.orig_headers); |
| 2022 std::replace(orig_headers.begin(), orig_headers.end(), '\n', '\0'); | 1994 std::replace(orig_headers.begin(), orig_headers.end(), '\n', '\0'); |
| 2023 scoped_refptr<HttpResponseHeaders> parsed( | 1995 scoped_refptr<HttpResponseHeaders> parsed( |
| 2024 new HttpResponseHeaders(orig_headers + '\0')); | 1996 new HttpResponseHeaders(orig_headers + '\0')); |
| 2025 int64_t content_size = parsed->GetContentLength(); | 1997 int64_t content_size = parsed->GetContentLength(); |
| 2026 std::string resulting_headers; | 1998 std::string resulting_headers; |
| 2027 | 1999 |
| 2028 // Update headers without replacing status line. | 2000 // Update headers without replacing status line. |
| 2029 parsed->UpdateWithNewRange(range, content_size, false); | 2001 parsed->UpdateWithNewRange(range, content_size, false); |
| 2030 parsed->GetNormalizedHeaders(&resulting_headers); | |
| 2031 EXPECT_EQ(std::string(test.expected_headers), resulting_headers); | |
| 2032 | 2002 |
| 2033 // Replace status line too. | 2003 // Replace status line too. |
| 2034 parsed->UpdateWithNewRange(range, content_size, true); | 2004 parsed->UpdateWithNewRange(range, content_size, true); |
| 2035 parsed->GetNormalizedHeaders(&resulting_headers); | |
| 2036 EXPECT_EQ(std::string(test.expected_headers_with_replaced_status), | |
| 2037 resulting_headers); | |
| 2038 } | 2005 } |
| 2039 | 2006 |
| 2040 const UpdateWithNewRangeTestData update_range_tests[] = { | 2007 const UpdateWithNewRangeTestData update_range_tests[] = { |
| 2041 { "HTTP/1.1 200 OK\n" | 2008 { "HTTP/1.1 200 OK\n" |
| 2042 "Content-Length: 450\n", | 2009 "Content-Length: 450\n", |
| 2043 | 2010 |
| 2044 "HTTP/1.1 200 OK\n" | 2011 "HTTP/1.1 200 OK\n" |
| 2045 "Content-Range: bytes 3-5/450\n" | 2012 "Content-Range: bytes 3-5/450\n" |
| 2046 "Content-Length: 3\n", | 2013 "Content-Length: 3\n", |
| 2047 | 2014 |
| (...skipping 29 matching lines...) Expand all Loading... |
| 2077 NetLogCaptureMode::IncludeCookiesAndCredentials())); | 2044 NetLogCaptureMode::IncludeCookiesAndCredentials())); |
| 2078 scoped_refptr<HttpResponseHeaders> recreated; | 2045 scoped_refptr<HttpResponseHeaders> recreated; |
| 2079 | 2046 |
| 2080 ASSERT_TRUE( | 2047 ASSERT_TRUE( |
| 2081 HttpResponseHeaders::FromNetLogParam(event_param.get(), &recreated)); | 2048 HttpResponseHeaders::FromNetLogParam(event_param.get(), &recreated)); |
| 2082 ASSERT_TRUE(recreated.get()); | 2049 ASSERT_TRUE(recreated.get()); |
| 2083 EXPECT_EQ(parsed->GetHttpVersion(), recreated->GetHttpVersion()); | 2050 EXPECT_EQ(parsed->GetHttpVersion(), recreated->GetHttpVersion()); |
| 2084 EXPECT_EQ(parsed->response_code(), recreated->response_code()); | 2051 EXPECT_EQ(parsed->response_code(), recreated->response_code()); |
| 2085 EXPECT_EQ(parsed->GetContentLength(), recreated->GetContentLength()); | 2052 EXPECT_EQ(parsed->GetContentLength(), recreated->GetContentLength()); |
| 2086 EXPECT_EQ(parsed->IsKeepAlive(), recreated->IsKeepAlive()); | 2053 EXPECT_EQ(parsed->IsKeepAlive(), recreated->IsKeepAlive()); |
| 2087 | |
| 2088 std::string normalized_parsed; | |
| 2089 parsed->GetNormalizedHeaders(&normalized_parsed); | |
| 2090 std::string normalized_recreated; | |
| 2091 parsed->GetNormalizedHeaders(&normalized_recreated); | |
| 2092 EXPECT_EQ(normalized_parsed, normalized_recreated); | |
| 2093 } | 2054 } |
| 2094 | 2055 |
| 2095 TEST_F(HttpResponseHeadersCacheControlTest, AbsentMaxAgeReturnsFalse) { | 2056 TEST_F(HttpResponseHeadersCacheControlTest, AbsentMaxAgeReturnsFalse) { |
| 2096 InitializeHeadersWithCacheControl("nocache"); | 2057 InitializeHeadersWithCacheControl("nocache"); |
| 2097 EXPECT_FALSE(headers()->GetMaxAgeValue(TimeDeltaPointer())); | 2058 EXPECT_FALSE(headers()->GetMaxAgeValue(TimeDeltaPointer())); |
| 2098 } | 2059 } |
| 2099 | 2060 |
| 2100 TEST_F(HttpResponseHeadersCacheControlTest, MaxAgeWithNoParameterRejected) { | 2061 TEST_F(HttpResponseHeadersCacheControlTest, MaxAgeWithNoParameterRejected) { |
| 2101 InitializeHeadersWithCacheControl("max-age=,private"); | 2062 InitializeHeadersWithCacheControl("max-age=,private"); |
| 2102 EXPECT_FALSE(headers()->GetMaxAgeValue(TimeDeltaPointer())); | 2063 EXPECT_FALSE(headers()->GetMaxAgeValue(TimeDeltaPointer())); |
| (...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2262 "Fri, 20 Jan 2011 10:40:08 GMT", "Fri, 20 Jan 2011 10:40:12 GMT", | 2223 "Fri, 20 Jan 2011 10:40:08 GMT", "Fri, 20 Jan 2011 10:40:12 GMT", |
| 2263 "Fri, 20 Jan 2011 10:40:14 GMT", 7}}; | 2224 "Fri, 20 Jan 2011 10:40:14 GMT", 7}}; |
| 2264 | 2225 |
| 2265 INSTANTIATE_TEST_CASE_P(HttpResponseHeaders, | 2226 INSTANTIATE_TEST_CASE_P(HttpResponseHeaders, |
| 2266 GetCurrentAgeTest, | 2227 GetCurrentAgeTest, |
| 2267 testing::ValuesIn(get_current_age_tests)); | 2228 testing::ValuesIn(get_current_age_tests)); |
| 2268 | 2229 |
| 2269 } // namespace | 2230 } // namespace |
| 2270 | 2231 |
| 2271 } // namespace net | 2232 } // namespace net |
| OLD | NEW |