[core] Use better types for modified / expires / etag

This commit is contained in:
John Firebaugh
2016-01-19 15:57:17 -08:00
parent c33ed50c98
commit 1c21d0fd4c
33 changed files with 231 additions and 169 deletions

View File

@@ -5,15 +5,19 @@
namespace mbgl {
Seconds HTTPRequestBase::parseCacheControl(const char *value) {
if (value) {
const auto cacheControl = http::CacheControl::parse(value);
if (cacheControl.maxAge) {
return toSeconds(SystemClock::now()) + Seconds(*cacheControl.maxAge);
}
optional<SystemTimePoint> HTTPRequestBase::parseCacheControl(const char *value) {
if (!value) {
return {};
}
return Seconds::zero();
const auto cacheControl = http::CacheControl::parse(value);
if (!cacheControl.maxAge) {
return {};
}
// Round trip through time_t to truncate fractional seconds.
return SystemClock::from_time_t(SystemClock::to_time_t(
SystemClock::now() + std::chrono::seconds(*cacheControl.maxAge)));
}
} // namespace mbgl