summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDan Goodliffe <dan@randomdan.homeip.net>2022-12-25 11:55:57 +0000
committerDan Goodliffe <dan@randomdan.homeip.net>2022-12-25 11:55:57 +0000
commit2c084f9b57f1b1d85d524bc77c6cef70c3e3151e (patch)
tree2a6bd05e8be0f1c42c8a5c3a665d02dfbbea4142
parentFix shadowing (diff)
downloadlibadhocutil-main.tar.bz2
libadhocutil-main.tar.xz
libadhocutil-main.zip
Update deprecated libcurl usageHEADlibadhocutil-0.9.2main
-rw-r--r--libadhocutil/curlHandle.cpp12
-rw-r--r--libadhocutil/curlHandle.h2
2 files changed, 7 insertions, 7 deletions
diff --git a/libadhocutil/curlHandle.cpp b/libadhocutil/curlHandle.cpp
index d7a91ae..2f375b5 100644
--- a/libadhocutil/curlHandle.cpp
+++ b/libadhocutil/curlHandle.cpp
@@ -24,8 +24,8 @@ namespace AdHoc::Net {
if (curl_headers) {
curl_slist_free_all(curl_headers);
}
- if (postS) {
- curl_formfree(postS);
+ if (mime) {
+ curl_mime_free(mime);
}
curl_easy_cleanup(curl_handle);
}
@@ -65,10 +65,10 @@ namespace AdHoc::Net {
void
CurlHandle::appendPost(const char * name, const char * value)
{
- CURLFORMcode r
- = curl_formadd(&postS, &postE, CURLFORM_PTRNAME, name, CURLFORM_PTRCONTENTS, value, CURLFORM_END);
- if (r == 0) {
- curl_easy_setopt(curl_handle, CURLOPT_HTTPPOST, postS);
+ if (auto part = curl_mime_addpart(mime)) {
+ curl_mime_name(part, name);
+ curl_mime_data(part, value, CURL_ZERO_TERMINATED);
+ curl_easy_setopt(curl_handle, CURLOPT_MIMEPOST, mime);
}
}
diff --git a/libadhocutil/curlHandle.h b/libadhocutil/curlHandle.h
index dd81989..dc6ff23 100644
--- a/libadhocutil/curlHandle.h
+++ b/libadhocutil/curlHandle.h
@@ -53,7 +53,7 @@ namespace AdHoc::Net {
CURL * curl_handle;
curl_slist * curl_headers {nullptr};
- curl_httppost *postS {nullptr}, *postE {nullptr};
+ curl_mime *mime{nullptr};
/// @endcond
};
using CurlHandlePtr = std::shared_ptr<CurlHandle>;