summaryrefslogtreecommitdiff
path: root/src/platform/response.cpp
blob: ce376380fac4ffca17cdbddb94acbe9dda369ee0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#include <mbgl/platform/response.hpp>
#include <curl/curl.h>

#include <cstdio>

namespace mbgl {
namespace platform {


void Response::setCacheControl(const char *value) {
    if (!value) {
        expires = -1;
        return;
    }

    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);
}

}
}