From 963ff1997d108c665f640703b9deae6fa4f38679 Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Sun, 5 Mar 2023 08:47:39 +0100 Subject: [PATCH] lib/curl/Easy: add methods SetXferInfoFunction(), SetMimePost() --- src/lib/curl/Easy.hxx | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/src/lib/curl/Easy.hxx b/src/lib/curl/Easy.hxx index 3bfcc0952..823516876 100644 --- a/src/lib/curl/Easy.hxx +++ b/src/lib/curl/Easy.hxx @@ -1,5 +1,5 @@ /* - * Copyright 2016-2021 Max Kellermann + * Copyright 2016-2023 Max Kellermann * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -27,8 +27,7 @@ * OF THE POSSIBILITY OF SUCH DAMAGE. */ -#ifndef CURL_EASY_HXX -#define CURL_EASY_HXX +#pragma once #include "Error.hxx" #include "String.hxx" @@ -128,6 +127,13 @@ public: 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) { SetOption(CURLOPT_NOSIGNAL, (long)value); } @@ -187,6 +193,10 @@ public: SetOption(CURLOPT_POSTFIELDSIZE, (long)size); } + void SetMimePost(const curl_mime *mime) { + SetOption(CURLOPT_MIMEPOST, mime); + } + template bool GetInfo(CURLINFO info, T value_r) const noexcept { return ::curl_easy_getinfo(handle, info, value_r) == CURLE_OK; @@ -217,5 +227,3 @@ public: return CurlString(curl_easy_escape(handle, string, length)); } }; - -#endif