lib/curl/Easy: add methods SetXferInfoFunction(), SetMimePost()

This commit is contained in:
Max Kellermann 2023-03-05 08:47:39 +01:00
parent 5c2a576546
commit 963ff1997d

View File

@ -1,5 +1,5 @@
/* /*
* Copyright 2016-2021 Max Kellermann <max.kellermann@gmail.com> * Copyright 2016-2023 Max Kellermann <max.kellermann@gmail.com>
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions * modification, are permitted provided that the following conditions
@ -27,8 +27,7 @@
* OF THE POSSIBILITY OF SUCH DAMAGE. * OF THE POSSIBILITY OF SUCH DAMAGE.
*/ */
#ifndef CURL_EASY_HXX #pragma once
#define CURL_EASY_HXX
#include "Error.hxx" #include "Error.hxx"
#include "String.hxx" #include "String.hxx"
@ -128,6 +127,13 @@ public:
SetOption(CURLOPT_NOPROGRESS, (long)value); SetOption(CURLOPT_NOPROGRESS, (long)value);
} }
void SetXferInfoFunction(curl_xferinfo_callback function,
void *data) {
SetOption(CURLOPT_XFERINFOFUNCTION, function);
SetOption(CURLOPT_XFERINFODATA, data);
SetNoProgress(false);
}
void SetNoSignal(bool value=true) { void SetNoSignal(bool value=true) {
SetOption(CURLOPT_NOSIGNAL, (long)value); SetOption(CURLOPT_NOSIGNAL, (long)value);
} }
@ -187,6 +193,10 @@ public:
SetOption(CURLOPT_POSTFIELDSIZE, (long)size); SetOption(CURLOPT_POSTFIELDSIZE, (long)size);
} }
void SetMimePost(const curl_mime *mime) {
SetOption(CURLOPT_MIMEPOST, mime);
}
template<typename T> template<typename T>
bool GetInfo(CURLINFO info, T value_r) const noexcept { bool GetInfo(CURLINFO info, T value_r) const noexcept {
return ::curl_easy_getinfo(handle, info, value_r) == CURLE_OK; return ::curl_easy_getinfo(handle, info, value_r) == CURLE_OK;
@ -217,5 +227,3 @@ public:
return CurlString(curl_easy_escape(handle, string, length)); return CurlString(curl_easy_escape(handle, string, length));
} }
}; };
#endif