Fix #250: Allow specifying a buffer when using Curl::verbose()

This commit is contained in:
Zach Borboa
2015-10-14 17:49:48 -07:00
parent fae59ddd24
commit 7430a2a954
2 changed files with 17 additions and 1 deletions
+2 -1
View File
@@ -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);
}
/**
+15
View File
@@ -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);
}
}