OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 794 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
805 { "HTTP/1.1 200 OK\n" | 805 { "HTTP/1.1 200 OK\n" |
806 "date: Wed, 28 Nov 2007 00:40:11 GMT\n" | 806 "date: Wed, 28 Nov 2007 00:40:11 GMT\n" |
807 "last-modified: Wed, 27 Nov 2007 08:00:00 GMT\n" | 807 "last-modified: Wed, 27 Nov 2007 08:00:00 GMT\n" |
808 "pragma: no-cache\n" | 808 "pragma: no-cache\n" |
809 "\n", | 809 "\n", |
810 true | 810 true |
811 }, | 811 }, |
812 // TODO(darin): add many many more tests here | 812 // TODO(darin): add many many more tests here |
813 }; | 813 }; |
814 base::Time request_time, response_time, current_time; | 814 base::Time request_time, response_time, current_time; |
815 base::Time::FromString(L"Wed, 28 Nov 2007 00:40:09 GMT", &request_time); | 815 base::Time::FromString("Wed, 28 Nov 2007 00:40:09 GMT", &request_time); |
816 base::Time::FromString(L"Wed, 28 Nov 2007 00:40:12 GMT", &response_time); | 816 base::Time::FromString("Wed, 28 Nov 2007 00:40:12 GMT", &response_time); |
817 base::Time::FromString(L"Wed, 28 Nov 2007 00:45:20 GMT", ¤t_time); | 817 base::Time::FromString("Wed, 28 Nov 2007 00:45:20 GMT", ¤t_time); |
818 | 818 |
819 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(tests); ++i) { | 819 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(tests); ++i) { |
820 std::string headers(tests[i].headers); | 820 std::string headers(tests[i].headers); |
821 HeadersToRaw(&headers); | 821 HeadersToRaw(&headers); |
822 scoped_refptr<net::HttpResponseHeaders> parsed( | 822 scoped_refptr<net::HttpResponseHeaders> parsed( |
823 new net::HttpResponseHeaders(headers)); | 823 new net::HttpResponseHeaders(headers)); |
824 | 824 |
825 bool requires_validation = | 825 bool requires_validation = |
826 parsed->RequiresValidation(request_time, response_time, current_time); | 826 parsed->RequiresValidation(request_time, response_time, current_time); |
827 EXPECT_EQ(tests[i].requires_validation, requires_validation); | 827 EXPECT_EQ(tests[i].requires_validation, requires_validation); |
(...skipping 843 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1671 new net::HttpResponseHeaders(orig_headers)); | 1671 new net::HttpResponseHeaders(orig_headers)); |
1672 | 1672 |
1673 std::string name(tests[i].new_status); | 1673 std::string name(tests[i].new_status); |
1674 parsed->ReplaceStatusLine(name); | 1674 parsed->ReplaceStatusLine(name); |
1675 | 1675 |
1676 std::string resulting_headers; | 1676 std::string resulting_headers; |
1677 parsed->GetNormalizedHeaders(&resulting_headers); | 1677 parsed->GetNormalizedHeaders(&resulting_headers); |
1678 EXPECT_EQ(std::string(tests[i].expected_headers), resulting_headers); | 1678 EXPECT_EQ(std::string(tests[i].expected_headers), resulting_headers); |
1679 } | 1679 } |
1680 } | 1680 } |
OLD | NEW |