Repository navigation
ext/curl: Fix curl_reset() and CURLOPT_POSTFIELDS keeping old request data - #25000
binaryfire wants to merge 3 commits into
Conversation
curl_reset() reset the write, header and read handlers but kept their callbacks, and it kept the CURLOPT_PRIVATE value and the CURLOPT_POSTFIELDS array. All of them stayed referenced until the handle was freed, CURLINFO_PRIVATE still returned the old value, and copies of a reset handle rebuilt the old file post fields.
Setting CURLOPT_POSTFIELDS again kept a previous array containing CURLFile or CURLStringFile objects, so curl_copy_handle() and clone rebuilt the old multipart body on the copy while the original handle sent the new value.
Switching the request method with CURLOPT_HTTPGET, CURLOPT_NOBODY, CURLOPT_POST, CURLOPT_UPLOAD or CURLOPT_PUT kept a CURLOPT_POSTFIELDS array containing CURLFile or CURLStringFile objects, so curl_copy_handle() and clone rebuilt the old multipart POST on the copy while the original handle used the new method.
|
Quoted below: written with Claude, an LLM, as CONTRIBUTING.md asks us to mark. The builds and test runs behind it are on my machine; the commands to repeat them are under the fold.
|
|
Thank you for your contribution. I agree that this is a bug. I expect PHP's curl_reset to have the same effect as curl_easy_reset:
So that means that CURLINFO_PRIVATE should be unavailable after a curl_reset. At first glance this PR looks good, but incomplete. There are other fields that are not reset, such as curl_errno. That does not necessarily have to be a blocker for this PR. |
I ran into this while working on Swoole's copy of ext/curl, which we keep in line with php-src.
The description below was written by Claude at my request, and I've reviewed it.