Don't include bogus last_modified = 0 in InputInfo when the resource didn't
have a last-modified header. (Noticed when storing these in dependencies tables).
This commit is contained in:
@@ -207,7 +207,9 @@ void Resource::FillInPartitionInputInfo(HashHint include_content_hash,
|
||||
void Resource::FillInPartitionInputInfoFromResponseHeaders(
|
||||
const ResponseHeaders& headers,
|
||||
InputInfo* input) {
|
||||
input->set_last_modified_time_ms(headers.last_modified_time_ms());
|
||||
if (headers.has_last_modified_time_ms()) {
|
||||
input->set_last_modified_time_ms(headers.last_modified_time_ms());
|
||||
}
|
||||
input->set_expiration_time_ms(headers.CacheExpirationTimeMs());
|
||||
input->set_date_ms(headers.date_ms());
|
||||
}
|
||||
|
||||
@@ -1745,7 +1745,8 @@ void CheckMatchesHeaders(const ResponseHeaders& headers,
|
||||
ASSERT_TRUE(input.has_type());
|
||||
EXPECT_EQ(InputInfo::CACHED, input.type());
|
||||
|
||||
ASSERT_TRUE(input.has_last_modified_time_ms());
|
||||
EXPECT_EQ(headers.has_last_modified_time_ms(),
|
||||
input.has_last_modified_time_ms());
|
||||
EXPECT_EQ(headers.last_modified_time_ms(), input.last_modified_time_ms());
|
||||
|
||||
ASSERT_TRUE(input.has_expiration_time_ms());
|
||||
@@ -1785,6 +1786,14 @@ TEST_F(ServerContextTest, FillInPartitionInputInfo) {
|
||||
ASSERT_TRUE(with_hash.has_input_content_hash());
|
||||
EXPECT_STREQ("zEEebBNnDlISRim4rIP30", with_hash.input_content_hash());
|
||||
EXPECT_FALSE(without_hash.has_input_content_hash());
|
||||
|
||||
resource->response_headers()->RemoveAll(HttpAttributes::kLastModified);
|
||||
resource->response_headers()->ComputeCaching();
|
||||
EXPECT_FALSE(resource->response_headers()->has_last_modified_time_ms());
|
||||
InputInfo without_last_modified;
|
||||
resource->FillInPartitionInputInfo(Resource::kOmitInputHash,
|
||||
&without_last_modified);
|
||||
CheckMatchesHeaders(*resource->response_headers(), without_last_modified);
|
||||
}
|
||||
|
||||
// Test of referer for BackgroundFetch: When the resource fetching request
|
||||
|
||||
@@ -246,6 +246,12 @@ void ResponseHeaders::set_reason_phrase(const StringPiece& reason_phrase) {
|
||||
reason_phrase.size());
|
||||
}
|
||||
|
||||
bool ResponseHeaders::has_last_modified_time_ms() const {
|
||||
DCHECK(!cache_fields_dirty_)
|
||||
<< "Call ComputeCaching() before last_modified_time_ms()";
|
||||
return proto()->has_last_modified_time_ms();
|
||||
}
|
||||
|
||||
int64 ResponseHeaders::last_modified_time_ms() const {
|
||||
DCHECK(!cache_fields_dirty_)
|
||||
<< "Call ComputeCaching() before last_modified_time_ms()";
|
||||
|
||||
@@ -224,6 +224,7 @@ class ResponseHeaders : public Headers<HttpResponseHeaders> {
|
||||
http_options_.implicit_cache_ttl_ms = ttl;
|
||||
}
|
||||
|
||||
bool has_last_modified_time_ms() const;
|
||||
int64 last_modified_time_ms() const;
|
||||
int64 date_ms() const; // Timestamp from Date header.
|
||||
bool has_date_ms() const;
|
||||
|
||||
@@ -1633,12 +1633,14 @@ TEST_F(ResponseHeadersTest, FixupMissingDate) {
|
||||
|
||||
TEST_F(ResponseHeadersTest, LastModifiedAsInt64) {
|
||||
response_headers_.Clear();
|
||||
EXPECT_FALSE(response_headers_.has_last_modified_time_ms());
|
||||
response_headers_.SetLastModified(MockTimer::kApr_5_2010_ms);
|
||||
response_headers_.ComputeCaching();
|
||||
EXPECT_STREQ("Mon, 05 Apr 2010 18:51:26 GMT", response_headers_.Lookup1(
|
||||
HttpAttributes::kLastModified));
|
||||
EXPECT_EQ(MockTimer::kApr_5_2010_ms,
|
||||
response_headers_.last_modified_time_ms());
|
||||
EXPECT_TRUE(response_headers_.has_last_modified_time_ms());
|
||||
}
|
||||
|
||||
TEST_F(ResponseHeadersTest, DoNotCorrectValidDate) {
|
||||
|
||||
Reference in New Issue
Block a user