mirror of
https://github.com/php-curl-class/php-curl-class.git
synced 2026-09-03 22:36:27 +00:00
Fix #250: Allow specifying a buffer when using Curl::verbose()
This commit is contained in:
+2
-1
@@ -795,7 +795,7 @@ 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.
|
||||
@@ -803,6 +803,7 @@ class Curl
|
||||
$this->setOpt(CURLINFO_HEADER_OUT, false);
|
||||
}
|
||||
$this->setOpt(CURLOPT_VERBOSE, $on);
|
||||
$this->setOpt(CURLOPT_STDERR, $output);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -2526,4 +2526,19 @@ class CurlTest extends PHPUnit_Framework_TestCase
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function testAlternativeStandardErrorOutput()
|
||||
{
|
||||
$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