From fae59ddd24aabe8235b31881e7f027ae1b9956e4 Mon Sep 17 00:00:00 2001 From: Zach Borboa Date: Wed, 14 Oct 2015 17:26:32 -0700 Subject: [PATCH 1/4] Turn off CURLINFO_HEADER_OUT when enabling verbose --- src/Curl/Curl.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/Curl/Curl.php b/src/Curl/Curl.php index 2fdf12e..0d035c6 100644 --- a/src/Curl/Curl.php +++ b/src/Curl/Curl.php @@ -797,6 +797,11 @@ class Curl */ public function verbose($on = true) { + // 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); } From 7430a2a95497aa18f646cc1708336314cbc9d505 Mon Sep 17 00:00:00 2001 From: Zach Borboa Date: Wed, 14 Oct 2015 17:49:48 -0700 Subject: [PATCH 2/4] Fix #250: Allow specifying a buffer when using Curl::verbose() --- src/Curl/Curl.php | 3 ++- tests/PHPCurlClass/PHPCurlClassTest.php | 15 +++++++++++++++ 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/src/Curl/Curl.php b/src/Curl/Curl.php index 0d035c6..b074ecf 100644 --- a/src/Curl/Curl.php +++ b/src/Curl/Curl.php @@ -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); } /** diff --git a/tests/PHPCurlClass/PHPCurlClassTest.php b/tests/PHPCurlClass/PHPCurlClassTest.php index 1bad997..910048b 100644 --- a/tests/PHPCurlClass/PHPCurlClassTest.php +++ b/tests/PHPCurlClass/PHPCurlClassTest.php @@ -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); + } } From 62e9bdf693e0ddc021486ce8bb475cdfa03bc092 Mon Sep 17 00:00:00 2001 From: Zach Borboa Date: Thu, 15 Oct 2015 09:56:51 -0700 Subject: [PATCH 3/4] Skip test on HHVM due to "Segmentation fault" --- tests/PHPCurlClass/PHPCurlClassTest.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/tests/PHPCurlClass/PHPCurlClassTest.php b/tests/PHPCurlClass/PHPCurlClassTest.php index 910048b..302aafd 100644 --- a/tests/PHPCurlClass/PHPCurlClassTest.php +++ b/tests/PHPCurlClass/PHPCurlClassTest.php @@ -2529,6 +2529,11 @@ 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(); From 99ef5d59059983fcce42fc63d46f330969162810 Mon Sep 17 00:00:00 2001 From: Zach Borboa Date: Thu, 15 Oct 2015 09:57:47 -0700 Subject: [PATCH 4/4] Bump minor version --- src/Curl/Curl.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Curl/Curl.php b/src/Curl/Curl.php index b074ecf..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;