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

View File

@@ -1,10 +1,11 @@
#ifndef MBGL_PLATFORM_PLATFORM
#define MBGL_PLATFORM_PLATFORM
#include <mbgl/platform/response.hpp>
#include <mbgl/util/uv.hpp>
#include <memory>
#include <functional>
#include <string>
namespace mbgl {
@@ -12,14 +13,6 @@ namespace platform {
class Request;
struct Response {
Response(std::function<void(Response *)> callback) : callback(callback) {}
int16_t code = -1;
std::string body;
std::string error_message;
std::function<void(Response *)> callback;
};
// Makes an HTTP request of a URL, preferrably on a background thread, and calls a function with the
// results in the original thread (which runs the libuv loop).
// If the loop pointer is NULL, the callback function will be called on an arbitrary thread.

View File

@@ -0,0 +1,29 @@
#ifndef MBGL_PLATFORM_RESPONSE
#define MBGL_PLATFORM_RESPONSE
#include <string>
#include <functional>
#include <ctime>
#include <mbgl/util/noncopyable.hpp>
namespace mbgl {
namespace platform {
struct Response : private util::noncopyable {
Response(std::function<void(Response *)> callback) : callback(callback) {}
int16_t code = -1;
std::string body;
std::string error_message;
std::time_t modified;
std::time_t expires;
std::function<void(Response *)> callback;
void setCacheControl(const char *value);
void setLastModified(const char *value);
};
}
}
#endif