On 8/27/22 10:17, Mayoi Hachikuji via curl-library wrote:
Hello,

`curl_mime_init` requires an existing *easy_handle*, but it's not clear
what its purpose actually is, as the only information (documentation and
general internet combined) I can seem to find is
it creates a handle to a new empty mime structure intended to be used
with *easy_handle*
and I don't know enough about libcurl internals to infer what this
actually means by reading the source code.

At the time of mime structure building, the easy handle is mainly used for error checking and reporting.

In particular, you cannot attach a structure as a subpart of another structure if both have not been created for the same easy handle.

The easy handle is also stored in the structures for later internal quick access to non-mime data.


The confusing part is that this does not immediately associate this
handle with the *easy_handle*. It still has to be added using
`curl_easy_setopt`.
If it were automatically added, subparts would be too, which is not what we want! In addition, this allows you to keep around more than one mime handle for the same easy handle and "swaps" them between requests.
Does it mean that it's okay to attach this handle to
any other *easy_handle* that's not the one I created this handle with?
No. You will even get an error if you do that.
If so, I guess it wouldn't need an *easy_handle*, but this word
"intended" to me has a conotation that it's not a hard dependency.

There's also ability to add curl_mime* to curl_mimepart* using
`curl_mime_subparts`, regarding the above, does it mean that they cannot
ever be mixed in regard to what handle each of them was created with?
As stated above, they can't be mixed.

What I want to be sure of is if
this curl_mime* can only ever be used with CURL* it was created with
is an invariant that I have to uphold for libcurl to work correctly.

The easy handle must always be used consistently.


Patrick
--
Unsubscribe: https://lists.haxx.se/listinfo/curl-library
Etiquette:   https://curl.se/mail/etiquette.html

Reply via email to