return get_partial_url(url).str();
}
+RemoteStorage::Backend::Failure
+failure_from_httplib_error(httplib::Error error)
+{
+ return error == httplib::Error::ConnectionTimeout
+ ? RemoteStorage::Backend::Failure::timeout
+ : RemoteStorage::Backend::Failure::error;
+}
+
HttpStorageBackend::HttpStorageBackend(const Params& params)
: m_url_path(get_url_path(params.url)),
m_http_client(get_url(params.url))
url_path,
to_string(result.error()),
static_cast<int>(result.error()));
- return nonstd::make_unexpected(Failure::error);
+ return nonstd::make_unexpected(failure_from_httplib_error(result.error()));
}
if (result->status < 200 || result->status >= 300) {
url_path,
to_string(result.error()),
static_cast<int>(result.error()));
- return nonstd::make_unexpected(Failure::error);
+ return nonstd::make_unexpected(
+ failure_from_httplib_error(result.error()));
}
if (result->status >= 200 && result->status < 300) {
url_path,
to_string(result.error()),
static_cast<int>(result.error()));
- return nonstd::make_unexpected(Failure::error);
+ return nonstd::make_unexpected(failure_from_httplib_error(result.error()));
}
if (result->status < 200 || result->status >= 300) {
LOG("Failed to put {} to http storage: status code: {}",
url_path,
result->status);
- return nonstd::make_unexpected(Failure::error);
+ return nonstd::make_unexpected(failure_from_httplib_error(result.error()));
}
return true;
url_path,
to_string(result.error()),
static_cast<int>(result.error()));
- return nonstd::make_unexpected(Failure::error);
+ return nonstd::make_unexpected(failure_from_httplib_error(result.error()));
}
if (result->status < 200 || result->status >= 300) {
LOG("Failed to delete {} from http storage: status code: {}",
url_path,
result->status);
- return nonstd::make_unexpected(Failure::error);
+ return nonstd::make_unexpected(failure_from_httplib_error(result.error()));
}
return true;