Skip to content

curl_mime_init man page: handle must be final target handle #10834

Closed
@CosmicToast

Description

@CosmicToast

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

bagder commented on Mar 24, 2023

@bagder
Member
added a commit that references this issue on Mar 24, 2023
jay

jay commented on Mar 25, 2023

@jay
Member

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.

curl 8.1.0-DEV (x86_64-pc-linux-gnu) libcurl/8.1.0-DEV OpenSSL/3.1.0 zlib/1.2.8 nghttp2/1.52.0 librtmp/2.3
Release-Date: [unreleased]
Protocols: dict file ftp ftps gopher gophers http https imap imaps ldap ldaps mqtt pop3 pop3s rtmp rtsp smb smbs smtp smtps telnet tftp
Features: alt-svc AsynchDNS Debug HSTS HTTP2 HTTPS-proxy IPv6 Largefile libz NTLM NTLM_WB SSL threadsafe TLS-SRP TrackMemory UnixSockets
monnerat

monnerat commented on Mar 25, 2023

@monnerat
Contributor

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

CosmicToast commented on Mar 25, 2023

@CosmicToast
Author

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.

added a commit that references this issue on Mar 25, 2023
b936c24
added a commit that references this issue on Jul 19, 2023
a0758da
added a commit that references this issue on Aug 14, 2024
61d4260
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      Participants

      @bagder@monnerat@jay@CosmicToast

      Issue actions

        curl_mime_init man page: handle must be final target handle · Issue #10834 · curl/curl