diff options
author | pauljensen@chromium.org <pauljensen@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-10-29 22:54:58 +0000 |
---|---|---|
committer | pauljensen@chromium.org <pauljensen@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-10-29 22:54:58 +0000 |
commit | 6e6acc10590856575a4c4c330197e828917dc995 (patch) | |
tree | 9ef1ac70dcf7723188a3d08222ce98d1933e1b1b /net/http/http_response_headers_unittest.cc | |
parent | e42285a3b4def2770cc3ad504a0d73d2d565a313 (diff) | |
download | chromium_src-6e6acc10590856575a4c4c330197e828917dc995.zip chromium_src-6e6acc10590856575a4c4c330197e828917dc995.tar.gz chromium_src-6e6acc10590856575a4c4c330197e828917dc995.tar.bz2 |
Default to GMT when parsing HTTP "Date", "Expires" and "Last-Modified" headers.
BUG=153759
TEST=net_unittests --gtest_filter=HttpResponseHeadersTest.DefaultDateToGMT
Review URL: https://chromiumcodereview.appspot.com/11269011
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@164762 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net/http/http_response_headers_unittest.cc')
-rw-r--r-- | net/http/http_response_headers_unittest.cc | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/net/http/http_response_headers_unittest.cc b/net/http/http_response_headers_unittest.cc index 981fa10..28d97dd 100644 --- a/net/http/http_response_headers_unittest.cc +++ b/net/http/http_response_headers_unittest.cc @@ -547,6 +547,36 @@ TEST(HttpResponseHeadersTest, EnumerateHeader_DateValued) { EXPECT_EQ("Wed, 01 Aug 2007 23:23:45 GMT", value); } +TEST(HttpResponseHeadersTest, DefaultDateToGMT) { + // Verify we make the best interpretation when parsing dates that incorrectly + // do not end in "GMT" as RFC2616 requires. + std::string headers = + "HTTP/1.1 200 OK\n" + "Date: Tue, 07 Aug 2007 23:10:55\n" + "Last-Modified: Tue, 07 Aug 2007 19:10:55 EDT\n" + "Expires: Tue, 07 Aug 2007 23:10:55 UTC\n"; + HeadersToRaw(&headers); + scoped_refptr<net::HttpResponseHeaders> parsed( + new net::HttpResponseHeaders(headers)); + base::Time expected_value; + ASSERT_TRUE(base::Time::FromString("Tue, 07 Aug 2007 23:10:55 GMT", + &expected_value)); + + base::Time value; + // When the timezone is missing, GMT is a good guess as its what RFC2616 + // requires. + EXPECT_TRUE(parsed->GetDateValue(&value)); + EXPECT_EQ(expected_value, value); + // If GMT is missing but an RFC822-conforming one is present, use that. + EXPECT_TRUE(parsed->GetLastModifiedValue(&value)); + EXPECT_EQ(expected_value, value); + // If an unknown timezone is present, treat like a missing timezone and + // default to GMT. The only example of a web server not specifying "GMT" + // used "UTC" which is equivalent to GMT. + if (parsed->GetExpiresValue(&value)) + EXPECT_EQ(expected_value, value); +} + TEST(HttpResponseHeadersTest, GetMimeType) { const ContentTypeTestData tests[] = { { "HTTP/1.1 200 OK\n" |