summaryrefslogtreecommitdiff
path: root/src/mbgl/storage/response.cpp
blob: a8bfbd43d9491917f452da8609848440e18db126 (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
#include <mbgl/storage/response.hpp>
#include <mbgl/util/chrono.hpp>
#include <mbgl/util/enum.hpp>

#include <iostream>
#include <cassert>

namespace mbgl {

MBGL_DEFINE_ENUM(ResourceStatus, {
    { ResourceStatus::Success, "Success" },
    { ResourceStatus::NotFoundError, "NotFoundError" },
    { ResourceStatus::ServerError, "ServerError" },
    { ResourceStatus::ConnectionError, "ConnectionError" },
    { ResourceStatus::RateLimitError, "RateLimitError" },
    { ResourceStatus::OtherError, "OtherError" },
});

Response::Response(const Response& res) {
    *this = res;
}

Response& Response::operator=(const Response& res) {
    error = res.error ? std::make_unique<Error>(*res.error) : nullptr;
    noContent = res.noContent;
    notModified = res.notModified;
    data = res.data;
    modified = res.modified;
    expires = res.expires;
    etag = res.etag;
    return *this;
}

Response::Error::Error(ResourceStatus reason_, std::string message_, optional<Timestamp> retryAfter_)
    : status(reason_), message(std::move(message_)), retryAfter(std::move(retryAfter_)) {
}

} // namespace mbgl