summaryrefslogtreecommitdiff
path: root/src/mbgl/storage/http_request_base.hpp
blob: 8f1caf7bdc217929f3959365936d31e2d5308fbf (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
32
33
34
35
36
37
38
39
#ifndef MBGL_STORAGE_HTTP_REQUEST_BASE
#define MBGL_STORAGE_HTTP_REQUEST_BASE

#include <mbgl/util/noncopyable.hpp>
#include <mbgl/util/chrono.hpp>

#include <memory>
#include <functional>
#include <utility>
#include <string>

namespace mbgl {

class Response;

class HTTPRequestBase : private util::noncopyable {
public:
    using Callback = std::function<void (std::shared_ptr<const Response> response)>;

    HTTPRequestBase(const std::string& url_, Callback notify_)
        : url(url_)
        , notify(std::move(notify_))
        , cancelled(false) {
    }

    virtual ~HTTPRequestBase() = default;
    virtual void cancel() { cancelled = true; };

protected:
    static Seconds parseCacheControl(const char *value);

    std::string url;
    Callback notify;
    bool cancelled;
};

} // namespace mbgl

#endif // MBGL_STORAGE_HTTP_REQUEST_BASE