Home » Networking » Net_Curl » Bug #7954
setOption() method doesn't work
Details
| Submitted | 2006-06-21 02:40 UTC |
|---|---|
| From | dagdamor at simps dot ru |
| Status | Bogus |
| Package | Net_Curl |
| PHP Version | 4.3.10 |
| Roadmaps | (Not assigned) |
Comments
[2006-06-21 02:40 UTC] dagdamor at simps dot ru
Description:
------------
Net_Curl::setOption() always returns FALSE since it doesn't create a cURL handle; neither does the constructor.
Test script:
---------------
<?php
require_once "Net/Curl.php";
if(isset($_REQUEST["check_referer"])) {
if(isset($_SERVER["HTTP_REFERER"]))
echo "Referer: $_SERVER[HTTP_REFERER]";
else echo "No Referer";
echo "<br />";
exit;
}
$url = "http://localhost/?check_referer=1";
$referer = "http://localhost/";
// Testing the Curl Object
$curl = new Net_Curl($url);
$curl->setOption(CURLOPT_REFERER, $referer);
echo $curl->execute();
// The following code does the same, but uses native curl_xxx functions instead
// Uncomment it to make sure that the curl_setopt function works properly
//$curl = curl_init($url);
//curl_setopt($curl, CURLOPT_REFERER, $referer);
//curl_exec($curl);
//curl_close($curl);
?>
Expected result:
----------------
Referer: http://localhost/
Actual result:
--------------
No Referer
[2006-06-21 20:36 UTC] jstump at php dot net
Thank you for taking the time to write to us, but this is not
a bug.
This is expected behavior. The examples script fetchPage.php
shows how to properly build a Net_Curl object. The reason I
don't create the curl instance in the constructor is because I
can't return an error if something bad happens from the
constructor.
[2006-06-22 02:46 UTC] dagdamor at simps dot ru
Oh, you mean that I have to call the create() method manually before doing something. ;)
In this case, you should give the public access to the method; due to the class source code, it's internal.
But I think you'd better either remove it or leave it internal to make the class more convenient and easy to understand.
Serge