fix
This commit is contained in:
parent
b7c87bed82
commit
56e27e3184
@ -24,17 +24,18 @@
|
|||||||
#include "utils/string.hpp"
|
#include "utils/string.hpp"
|
||||||
|
|
||||||
namespace repertory::curl::requests {
|
namespace repertory::curl::requests {
|
||||||
auto http_put_file::set_method(CURL *curl,
|
auto http_put_file::set_method(CURL *curl, stop_type &stop_requested) const
|
||||||
stop_type &stop_requested) const -> bool {
|
-> bool {
|
||||||
curl_easy_setopt(curl, CURLOPT_CUSTOMREQUEST, "PUT");
|
curl_easy_setopt(curl, CURLOPT_CUSTOMREQUEST, "PUT");
|
||||||
curl_easy_setopt(curl, CURLOPT_UPLOAD, 1L);
|
|
||||||
|
|
||||||
if (source_path.empty()) {
|
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;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (reader) {
|
if (reader) {
|
||||||
|
curl_easy_setopt(curl, CURLOPT_UPLOAD, 1L);
|
||||||
curl_easy_setopt(curl, CURLOPT_READDATA, reader.get());
|
curl_easy_setopt(curl, CURLOPT_READDATA, reader.get());
|
||||||
curl_easy_setopt(
|
curl_easy_setopt(
|
||||||
curl, CURLOPT_READFUNCTION,
|
curl, CURLOPT_READFUNCTION,
|
||||||
@ -54,10 +55,17 @@ auto http_put_file::set_method(CURL *curl,
|
|||||||
}
|
}
|
||||||
|
|
||||||
auto file_size = read_info->file->size();
|
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_READDATA, read_info.get());
|
||||||
curl_easy_setopt(curl, CURLOPT_READFUNCTION, read_file_data);
|
curl_easy_setopt(curl, CURLOPT_READFUNCTION, read_file_data);
|
||||||
curl_easy_setopt(curl, CURLOPT_INFILESIZE_LARGE, file_size);
|
curl_easy_setopt(curl, CURLOPT_INFILESIZE_LARGE, file_size);
|
||||||
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user