OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 <algorithm> | 5 #include <algorithm> |
6 | 6 |
7 #include "base/basictypes.h" | 7 #include "base/basictypes.h" |
8 #include "base/pickle.h" | 8 #include "base/pickle.h" |
9 #include "base/time.h" | 9 #include "base/time.h" |
10 #include "net/http/http_response_headers.h" | 10 #include "net/http/http_response_headers.h" |
(...skipping 781 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
792 { "HTTP/1.1 200 OK\n" | 792 { "HTTP/1.1 200 OK\n" |
793 "date: Wed, 28 Nov 2007 00:40:11 GMT\n" | 793 "date: Wed, 28 Nov 2007 00:40:11 GMT\n" |
794 "last-modified: Wed, 27 Nov 2007 08:00:00 GMT\n" | 794 "last-modified: Wed, 27 Nov 2007 08:00:00 GMT\n" |
795 "pragma: no-cache\n" | 795 "pragma: no-cache\n" |
796 "\n", | 796 "\n", |
797 true | 797 true |
798 }, | 798 }, |
799 // TODO(darin): add many many more tests here | 799 // TODO(darin): add many many more tests here |
800 }; | 800 }; |
801 base::Time request_time, response_time, current_time; | 801 base::Time request_time, response_time, current_time; |
802 base::Time::FromString(L"Wed, 28 Nov 2007 00:40:09 GMT", &request_time); | 802 base::Time::FromString("Wed, 28 Nov 2007 00:40:09 GMT", &request_time); |
803 base::Time::FromString(L"Wed, 28 Nov 2007 00:40:12 GMT", &response_time); | 803 base::Time::FromString("Wed, 28 Nov 2007 00:40:12 GMT", &response_time); |
804 base::Time::FromString(L"Wed, 28 Nov 2007 00:45:20 GMT", ¤t_time); | 804 base::Time::FromString("Wed, 28 Nov 2007 00:45:20 GMT", ¤t_time); |
805 | 805 |
806 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(tests); ++i) { | 806 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(tests); ++i) { |
807 std::string headers(tests[i].headers); | 807 std::string headers(tests[i].headers); |
808 HeadersToRaw(&headers); | 808 HeadersToRaw(&headers); |
809 scoped_refptr<net::HttpResponseHeaders> parsed( | 809 scoped_refptr<net::HttpResponseHeaders> parsed( |
810 new net::HttpResponseHeaders(headers)); | 810 new net::HttpResponseHeaders(headers)); |
811 | 811 |
812 bool requires_validation = | 812 bool requires_validation = |
813 parsed->RequiresValidation(request_time, response_time, current_time); | 813 parsed->RequiresValidation(request_time, response_time, current_time); |
814 EXPECT_EQ(tests[i].requires_validation, requires_validation); | 814 EXPECT_EQ(tests[i].requires_validation, requires_validation); |
(...skipping 837 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1652 new net::HttpResponseHeaders(orig_headers)); | 1652 new net::HttpResponseHeaders(orig_headers)); |
1653 | 1653 |
1654 std::string name(tests[i].new_status); | 1654 std::string name(tests[i].new_status); |
1655 parsed->ReplaceStatusLine(name); | 1655 parsed->ReplaceStatusLine(name); |
1656 | 1656 |
1657 std::string resulting_headers; | 1657 std::string resulting_headers; |
1658 parsed->GetNormalizedHeaders(&resulting_headers); | 1658 parsed->GetNormalizedHeaders(&resulting_headers); |
1659 EXPECT_EQ(std::string(tests[i].expected_headers), resulting_headers); | 1659 EXPECT_EQ(std::string(tests[i].expected_headers), resulting_headers); |
1660 } | 1660 } |
1661 } | 1661 } |
OLD | NEW |