Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

After having used CURLOPT_MIMEPOST once, setting it to NULL does not reset to empty POST #6455

Closed
bagder opened this issue Jan 14, 2021 · 0 comments

Comments

@bagder
Copy link
Member

@bagder bagder commented Jan 14, 2021

Forwarded from an issue posted by Christoph M. Becker on the mailing list

I did this

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.

    curl_mime_init(handle);
    part = curl_mime_addpart(mime);
    // initialize part
    curl_easy_setopt(handle, CURLOPT_MIMEPOST, mime);
    curl_easy_perform(handle);
    curl_mime_free(mime);
    curl_easy_setopt(handle, CURLOPT_MIMEPOST, NULL);
    curl_easy_perform(handle);

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?

I expected the following

The second *perform() to do an empty POST

curl/libcurl version

current git master

operating system

any

bagder added a commit that referenced this issue Jan 14, 2021
... so that a function can first use MIMEPOST and then set it to NULL to
reset it back to a blank POST.

Added test 584 to verify the fix.

Reported-by: Christoph M. Becker

Fixes #6455
@bagder bagder closed this in 1123a0e Jan 15, 2021
cmb69 added a commit to cmb69/php-src that referenced this issue Jan 15, 2021
This is mainly to work around curl/curl#6455,
but not building the mime structure for empty hashtables is a general
performance optimization, so we do not restrict it to affected cURL
versions (7.56.0 to 7.75.0).

The minor change to bug79033.phpt is unexpected, but should not matter
in practice.
php-pulls pushed a commit to php/php-src that referenced this issue Jan 18, 2021
This is mainly to work around curl/curl#6455,
but not building the mime structure for empty hashtables is a general
performance optimization, so we do not restrict it to affected cURL
versions (7.56.0 to 7.75.0).

The minor change to bug79033.phpt is unexpected, but should not matter
in practice.

Closes GH-6606.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

1 participant