Merge pull request #251 from zachborboa/master

Allow specifying a buffer when using Curl::verbose()
This commit is contained in:
Zach Borboa
2015-10-15 10:07:14 -07:00
2 changed files with 28 additions and 2 deletions
+8 -2
View File
@@ -4,7 +4,7 @@ namespace Curl;
class Curl
{
const VERSION = '4.7.1';
const VERSION = '4.8.0';
const DEFAULT_TIMEOUT = 30;
public $curl;
@@ -795,9 +795,15 @@ class Curl
* @access public
* @param $on
*/
public function verbose($on = true)
public function verbose($on = true, $output=STDERR)
{
// Turn off CURLINFO_HEADER_OUT for verbose to work. This has the side
// effect of causing Curl::requestHeaders to be empty.
if ($on) {
$this->setOpt(CURLINFO_HEADER_OUT, false);
}
$this->setOpt(CURLOPT_VERBOSE, $on);
$this->setOpt(CURLOPT_STDERR, $output);
}
/**
+20
View File
@@ -2526,4 +2526,24 @@ class CurlTest extends PHPUnit_Framework_TestCase
}
}
}
public function testAlternativeStandardErrorOutput()
{
// Skip test on HHVM due to "Segmentation fault".
if (defined('HHVM_VERSION')) {
return;
}
$buffer = fopen('php://memory', 'w+');
$curl = new Curl();
$curl->verbose(true, $buffer);
$curl->post(Test::TEST_URL);
rewind($buffer);
$stderr = stream_get_contents($buffer);
fclose($buffer);
$this->assertNotEmpty($stderr);
}
}