summaryrefslogtreecommitdiff
path: root/libcurl
diff options
context:
space:
mode:
authorB. Stack <bgstack15@gmail.com>2022-10-19 10:53:07 -0400
committerB. Stack <bgstack15@gmail.com>2022-10-19 10:53:07 -0400
commita53560254596460a4778a27f50b89ce92f810055 (patch)
tree551fdc08cbece3cca567d04870b91eaa115a4675 /libcurl
parentMerge branch 'b11.26' into 'master' (diff)
downloadFreeFileSync-a53560254596460a4778a27f50b89ce92f810055.tar.gz
FreeFileSync-a53560254596460a4778a27f50b89ce92f810055.tar.bz2
FreeFileSync-a53560254596460a4778a27f50b89ce92f810055.zip
add upstream 11.2711.27
Diffstat (limited to 'libcurl')
-rw-r--r--libcurl/curl_wrap.cpp11
-rw-r--r--libcurl/curl_wrap.h2
2 files changed, 7 insertions, 6 deletions
diff --git a/libcurl/curl_wrap.cpp b/libcurl/curl_wrap.cpp
index 05fedb57..5ec56ed3 100644
--- a/libcurl/curl_wrap.cpp
+++ b/libcurl/curl_wrap.cpp
@@ -66,7 +66,7 @@ HttpSession::Result HttpSession::perform(const std::string& serverRelPath,
const std::vector<std::string>& extraHeaders, const std::vector<CurlOption>& extraOptions,
const std::function<void (std::span<const char> buf)>& writeResponse /*throw X*/, //optional
const std::function<size_t(std::span< char> buf)>& readRequest /*throw X*/, //optional; return "bytesToRead" bytes unless end of stream!
- const std::function<void (const std::string_view& header)>& receiveHeader /*throw X*/,
+ const std::function<void(const std::string_view& header)>& receiveHeader /*throw X*/,
int timeoutSec) //throw SysError, X
{
if (!easyHandle_)
@@ -219,15 +219,16 @@ HttpSession::Result HttpSession::perform(const std::string& serverRelPath,
/**/options.emplace_back(CURLOPT_UPLOAD, 1); //issues HTTP PUT
options.emplace_back(CURLOPT_READDATA, &getBytesToSend);
options.emplace_back(CURLOPT_READFUNCTION, getBytesToSendWrapper);
- //{CURLOPT_UPLOAD_BUFFERSIZE, 256 * 1024} -> defaults is 64 kB. apparently no performance improvement for larger buffers like 256 kB
+ //{CURLOPT_UPLOAD_BUFFERSIZE, 256 * 1024} -> default is 64 kB. apparently no performance improvement for larger buffers like 256 kB
+
+ //Contradicting options: CURLOPT_READFUNCTION, CURLOPT_POSTFIELDS:
+ if (std::any_of(extraOptions.begin(), extraOptions.end(), [](const CurlOption& o) { return o.option == CURLOPT_POSTFIELDS; }))
+ /**/ throw std::logic_error("Contract violation! " + std::string(__FILE__) + ':' + numberTo<std::string>(__LINE__));
}
if (std::any_of(extraOptions.begin(), extraOptions.end(), [](const CurlOption& o) { return o.option == CURLOPT_WRITEFUNCTION || o.option == CURLOPT_READFUNCTION; }))
/**/ throw std::logic_error("Contract violation! " + std::string(__FILE__) + ':' + numberTo<std::string>(__LINE__)); //Option already used here!
- if (readRequest && std::any_of(extraOptions.begin(), extraOptions.end(), [](const CurlOption& o) { return o.option == CURLOPT_POSTFIELDS; }))
- /**/ throw std::logic_error("Contract violation! " + std::string(__FILE__) + ':' + numberTo<std::string>(__LINE__)); //Contradicting options: CURLOPT_READFUNCTION, CURLOPT_POSTFIELDS
-
//---------------------------------------------------
curl_slist* headers = nullptr; //"libcurl will not copy the entire list so you must keep it!"
ZEN_ON_SCOPE_EXIT(::curl_slist_free_all(headers));
diff --git a/libcurl/curl_wrap.h b/libcurl/curl_wrap.h
index ea91072c..3dbdc3ba 100644
--- a/libcurl/curl_wrap.h
+++ b/libcurl/curl_wrap.h
@@ -55,7 +55,7 @@ public:
const std::vector<std::string>& extraHeaders, const std::vector<CurlOption>& extraOptions,
const std::function<void (std::span<const char> buf)>& writeResponse /*throw X*/, //optional
const std::function<size_t(std::span< char> buf)>& readRequest /*throw X*/, //optional; return "bytesToRead" bytes unless end of stream!
- const std::function<void (const std::string_view& header)>& receiveHeader /*throw X*/,
+ const std::function<void(const std::string_view& header)>& receiveHeader /*throw X*/,
int timeoutSec); //throw SysError, X
std::chrono::steady_clock::time_point getLastUseTime() const { return lastSuccessfulUseTime_; }
bgstack15