diff --git a/src/Curl/Curl.php b/src/Curl/Curl.php index 2fdf12e..228b52f 100644 --- a/src/Curl/Curl.php +++ b/src/Curl/Curl.php @@ -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); } /** diff --git a/tests/PHPCurlClass/PHPCurlClassTest.php b/tests/PHPCurlClass/PHPCurlClassTest.php index 1bad997..302aafd 100644 --- a/tests/PHPCurlClass/PHPCurlClassTest.php +++ b/tests/PHPCurlClass/PHPCurlClassTest.php @@ -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); + } }