Closed
Description
easy_handle is used for part separator randomization and error reporting. It does not need to be the final target handle.
This is incorrect, easy_handle must be the exact handle that the curl_mime will be given to, at least with HTTP.
To reproduce:
#include <assert.h>
#include <curl/curl.h>
int main() {
CURL *handle = curl_easy_init();
CURL *cinit = curl_easy_init();
curl_mime *mime = curl_mime_init(cinit);
curl_easy_setopt(handle, CURLOPT_URL, "https://pie.dev/post");
curl_easy_setopt(handle, CURLOPT_POST, 1);
assert(curl_easy_setopt(handle, CURLOPT_MIMEPOST, mime) == CURLE_OK); // this throws
curl_easy_perform(handle);
return 0;
}
If the example is changed to curl_mime_init(handle)
, everything works as expected.
Activity
bagder commentedon Mar 24, 2023
/cc @monnerat
native: fix mime stuff
jay commentedon Mar 25, 2023
What's your curl_version()? I can't reproduce this. I tried curl-8_0_1 and master fe55a63 2023-03-24, in Windows and Linux.
monnerat commentedon Mar 25, 2023
This works perfectly.
IMO, you probably run your binary with an old shared library (< 7.87.0). Printing curl_version() will give you a clue.
Ref: eb559c8
CosmicToast commentedon Mar 25, 2023
I was testing against multiple curl versions and platforms, specifically 7.85.0, 7.86.0, and 8.0.1.
The latter was last, leading to the conclusion, sorry!
Would it be possible to note the version in which the requirement was relaxed?
Many people still use those curl versions, and for libcurl wrappers (like what I'm writing) you do need to make sure things work on such older versions.
doc: curl_mime_init() strong easy handle binding has been relaxed in …
doc: curl_mime_init() strong easy handle binding has been relaxed in …
doc: curl_mime_init() strong easy handle binding has been relaxed in …