curl / Mailing Lists / curl-library / Single Mail
Buy commercial curl support from WolfSSL. We help you work out your issues, debug your libcurl applications, use the API, port to new platforms, add new features and more. With a team lead by the curl founder himself.

curl_mime_* API: how to send post request with empty body?

From: Christoph M. Becker via curl-library <>
Date: Mon, 11 Jan 2021 17:05:17 +0100

Hi all,

I wanted to send a post request with an empty body, and found that

    curl_easy_setopt(handle, CURLOPT_MIMEPOST, NULL);

allows me to do so. But it does not work to reset a formerly set
mimepost, e.g.

    part = curl_mime_addpart(mime);
    // initialize part
    curl_easy_setopt(handle, CURLOPT_MIMEPOST, mime);

    curl_easy_setopt(handle, CURLOPT_MIMEPOST, NULL);

The second curl_easy_perform() call returns CURLE_SEND_FAIL_REWIND.
Some debugging showed that part->state.state is not reset to
MIMESTATE_BEGIN in cleanup_part_content(). Is this an oversight, or am
I missing something?

Received on 2021-01-11