summaryrefslogtreecommitdiff
path: root/src/storage/response.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/storage/response.cpp')
-rw-r--r--src/storage/response.cpp22
1 files changed, 22 insertions, 0 deletions
diff --git a/src/storage/response.cpp b/src/storage/response.cpp
new file mode 100644
index 0000000000..cdaf33e4e4
--- /dev/null
+++ b/src/storage/response.cpp
@@ -0,0 +1,22 @@
+#include <mbgl/storage/response.hpp>
+
+#include <chrono>
+
+namespace mbgl {
+
+int64_t Response::parseCacheControl(const char *value) {
+ if (value) {
+ uint64_t 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;
+}
+
+}