fix
This commit is contained in:
parent
b7c87bed82
commit
56e27e3184
@ -24,17 +24,18 @@
|
||||
#include "utils/string.hpp"
|
||||
|
||||
namespace repertory::curl::requests {
|
||||
auto http_put_file::set_method(CURL *curl,
|
||||
stop_type &stop_requested) const -> bool {
|
||||
auto http_put_file::set_method(CURL *curl, stop_type &stop_requested) const
|
||||
-> bool {
|
||||
curl_easy_setopt(curl, CURLOPT_CUSTOMREQUEST, "PUT");
|
||||
curl_easy_setopt(curl, CURLOPT_UPLOAD, 1L);
|
||||
|
||||
if (source_path.empty()) {
|
||||
curl_easy_setopt(curl, CURLOPT_INFILESIZE_LARGE, 0L);
|
||||
curl_easy_setopt(curl, CURLOPT_INFILE, nullptr);
|
||||
curl_easy_setopt(curl, CURLOPT_INFILESIZE, 0L);
|
||||
return true;
|
||||
}
|
||||
|
||||
if (reader) {
|
||||
curl_easy_setopt(curl, CURLOPT_UPLOAD, 1L);
|
||||
curl_easy_setopt(curl, CURLOPT_READDATA, reader.get());
|
||||
curl_easy_setopt(
|
||||
curl, CURLOPT_READFUNCTION,
|
||||
@ -49,16 +50,23 @@ auto http_put_file::set_method(CURL *curl,
|
||||
utils::file::file::open_or_create_file(source_path),
|
||||
});
|
||||
|
||||
if (not *read_info->file) {
|
||||
if (not*read_info->file) {
|
||||
return false;
|
||||
}
|
||||
|
||||
auto file_size = read_info->file->size();
|
||||
if (file_size > 0U) {
|
||||
curl_easy_setopt(curl, CURLOPT_INFILE, nullptr);
|
||||
curl_easy_setopt(curl, CURLOPT_INFILESIZE, 0L);
|
||||
return true;
|
||||
}
|
||||
|
||||
curl_easy_setopt(curl, CURLOPT_UPLOAD, 1L);
|
||||
curl_easy_setopt(curl, CURLOPT_READDATA, read_info.get());
|
||||
curl_easy_setopt(curl, CURLOPT_READFUNCTION, read_file_data);
|
||||
curl_easy_setopt(curl, CURLOPT_INFILESIZE_LARGE, file_size);
|
||||
}
|
||||
|
||||
return true;
|
||||
return true;
|
||||
}
|
||||
} // namespace repertory::curl::requests
|
||||
|
Loading…
x
Reference in New Issue
Block a user