[core] Replace time_t with std::chrono::seconds

Added aliases for std::chrono typedefs (eg. 'Seconds' for
std::chrono::seconds). These aliases are used together with templated
helper functions to replace time_t with std::chrono::seconds for most
cases, in particular for 'modified' and 'expires' values in Response.
This commit is contained in:
Bruno de Oliveira Abinader
2015-11-25 13:30:32 +02:00
parent 4475f54860
commit 31fd2822f5
30 changed files with 184 additions and 121 deletions

View File

@@ -129,8 +129,8 @@ HTTPAndroidRequest::HTTPAndroidRequest(HTTPAndroidContext* context_, const Resou
if (existingResponse) {
if (!existingResponse->etag.empty()) {
etagStr = existingResponse->etag;
} else if (existingResponse->modified) {
modifiedStr = util::rfc1123(existingResponse->modified);
} else if (existingResponse->modified != Seconds::zero()) {
modifiedStr = util::rfc1123(existingResponse->modified.count());
}
}
@@ -195,11 +195,11 @@ void HTTPAndroidRequest::onResponse(int code, std::string message, std::string e
response = std::make_unique<Response>();
using Error = Response::Error;
response->modified = parse_date(modified.c_str());
response->modified = Seconds(parse_date(modified.c_str()));
response->etag = etag;
response->expires = parseCacheControl(cacheControl.c_str());
if (!expires.empty()) {
response->expires = parse_date(expires.c_str());
response->expires = Seconds(parse_date(expires.c_str()));
}
response->data = std::make_shared<std::string>(body);