php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #48208 curl_copy_handle() loses CURLOPT_POSTFIELDS option after original is closed
Submitted: 2009-05-09 14:10 UTC Modified: 2009-12-22 01:00 UTC
From: rick at meritos dot nl Assigned: pajoye (profile)
Status: No Feedback Package: cURL related
PHP Version: 5.3.0RC2 OS: Linux
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: rick at meritos dot nl
New email:
PHP Version: OS:

 

 [2009-05-09 14:10 UTC] rick at meritos dot nl
Description:
------------
After a curl handle is copied and the original closed with curl_close(), the copy no longer seems to contain the CURLOPT_POSTFIELDS option.

If the original is excecuted first, things get even stranger, the return value of curl_exec() on the copy seems to be borked.

Reproduce code:
---------------
  $url = "http://www.example.com/get.php?test=getpost";
  $ch = curl_init();
  curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
  curl_setopt($ch, CURLOPT_POST, 1);
  curl_setopt($ch, CURLOPT_POSTFIELDS, "Hello=World&Foo=Bar&Person=John%20Doe");
  curl_setopt($ch, CURLOPT_URL, $url); 
  $copy = curl_copy_handle($ch);
  curl_close($ch);
 
  $curl_content = curl_exec($copy);
  var_dump( $curl_content );

Expected result:
----------------
string(163) "array(1) {
  ["test"]=>
  string(7) "getpost"
}
array(3) {
  ["Hello"]=>
  string(5) "World"
  ["Foo"]=>
  string(3) "Bar"
  ["Person"]=>
  string(8) "John Doe"
}

Actual result:
--------------
string(61) "array(1) {
  ["test"]=>
  string(7) "getpost"
}
array(0) {
}
"

Note: comment out the curl_close($ch); , and it will return the expected result.

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2009-05-09 19:11 UTC] jani@php.net
Please try using this CVS snapshot:

  http://snaps.php.net/php5.2-latest.tar.gz
 
For Windows:

  http://windows.php.net/snapshots/


 [2009-05-10 08:43 UTC] pajoye@php.net
Please do not ask generecally to try a snapshot when they use the freshly release RC2 :)

I have to verify why curl_easy_duphandle does not copy the POST data.
 [2009-05-10 16:24 UTC] jani@php.net
I wanted to know if this happens also in PHP_5_2 branch so we you don't 
go and fix stuff only in PHP_5_3..
 [2009-05-18 01:00 UTC] php-bugs at lists dot php dot net
No feedback was provided for this bug for over a week, so it is
being suspended automatically. If you are able to provide the
information that was originally requested, please do so and change
the status of the bug back to "Open".
 [2009-12-15 00:42 UTC] felipe@php.net
Please try using this snapshot:

  http://snaps.php.net/php5.3-latest.tar.gz
 
For Windows:

  http://windows.php.net/snapshots/


 [2009-12-22 01:00 UTC] php-bugs at lists dot php dot net
No feedback was provided for this bug for over a week, so it is
being suspended automatically. If you are able to provide the
information that was originally requested, please do so and change
the status of the bug back to "Open".
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Wed Oct 16 05:01:27 2024 UTC