Files
MapLibreParticleLab/src/mbgl/storage/response.cpp
2014-12-04 20:02:50 +01:00

23 lines
618 B
C++

#include <mbgl/storage/response.hpp>
#include <chrono>
namespace mbgl {
int64_t Response::parseCacheControl(const char *value) {
if (value) {
unsigned long long seconds = 0;
// TODO: cache-control may contain other information as well:
// http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.9
if (std::sscanf(value, "max-age=%llu", &seconds) == 1) {
return std::chrono::duration_cast<std::chrono::seconds>(
std::chrono::system_clock::now().time_since_epoch()).count() +
seconds;
}
}
return -1;
}
}