mirror of
https://github.com/php-curl-class/php-curl-class.git
synced 2026-08-27 18:50:43 +00:00
Merge pull request #251 from zachborboa/master
Allow specifying a buffer when using Curl::verbose()
This commit is contained in:
+8
-2
@@ -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);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user