parse cache-control and last-modified headers

This commit is contained in:
Konstantin Käfer
2014-08-25 16:56:56 +02:00
parent 28446bed24
commit b94635f704
8 changed files with 121 additions and 15 deletions

26
src/platform/response.cpp Normal file
View File

@@ -0,0 +1,26 @@
#include <mbgl/platform/response.hpp>
#include <curl/curl.h>
#include <cstdio>
namespace mbgl {
namespace platform {
void Response::setCacheControl(const char *value) {
int 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=%u", &seconds) == 1) {
if (std::time(&expires) != -1) {
expires += seconds;
}
}
}
void Response::setLastModified(const char *value) {
modified = curl_getdate(value, nullptr);
}
}
}