Files
MapLibreParticleLab/src/mbgl/storage/http_request_base.cpp
2016-01-21 11:22:11 -08:00

24 lines
606 B
C++

#include <mbgl/storage/http_request_base.hpp>
#include <mbgl/util/http_header.hpp>
#include <mbgl/util/chrono.hpp>
namespace mbgl {
optional<SystemTimePoint> HTTPRequestBase::parseCacheControl(const char *value) {
if (!value) {
return {};
}
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