Skip to content
This repository was archived by the owner on Sep 22, 2022. It is now read-only.

Commit 7430a2a

Browse files
committed
Fix php-curl-class#250: Allow specifying a buffer when using Curl::verbose()
1 parent fae59dd commit 7430a2a

File tree

2 files changed

+17
-1
lines changed

2 files changed

+17
-1
lines changed

src/Curl/Curl.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -795,14 +795,15 @@ public function unsetHeader($key)
795795
* @access public
796796
* @param $on
797797
*/
798-
public function verbose($on = true)
798+
public function verbose($on = true, $output=STDERR)
799799
{
800800
// Turn off CURLINFO_HEADER_OUT for verbose to work. This has the side
801801
// effect of causing Curl::requestHeaders to be empty.
802802
if ($on) {
803803
$this->setOpt(CURLINFO_HEADER_OUT, false);
804804
}
805805
$this->setOpt(CURLOPT_VERBOSE, $on);
806+
$this->setOpt(CURLOPT_STDERR, $output);
806807
}
807808

808809
/**

tests/PHPCurlClass/PHPCurlClassTest.php

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2526,4 +2526,19 @@ public function testMemoryLeak()
25262526
}
25272527
}
25282528
}
2529+
2530+
public function testAlternativeStandardErrorOutput()
2531+
{
2532+
$buffer = fopen('php://memory', 'w+');
2533+
2534+
$curl = new Curl();
2535+
$curl->verbose(true, $buffer);
2536+
$curl->post(Test::TEST_URL);
2537+
2538+
rewind($buffer);
2539+
$stderr = stream_get_contents($buffer);
2540+
fclose($buffer);
2541+
2542+
$this->assertNotEmpty($stderr);
2543+
}
25292544
}

0 commit comments

Comments
 (0)