From: matteo at beccati dot com Operating system: Win32 (WinXP) PHP version: 4.3.4 PHP Bug Type: cURL related Bug description: CURLOPT_RETURNTRANSFER and CURLOPT_CUSTOMREQUEST incompatibility?
Description: ------------ Trying to help a friend which wanted to do a curl HEAD request with php (just like the shell curl -I does), I wrote down this code, without much checking: $ch = curl_init('http://foo/bar.html'); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_HEADER, true); curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'HEAD'); var_dump(curl_exec($ch)); In fact he tried it and told me it doesn't work, while this does: $ch = curl_init('http://foo/bar.html'); //curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_HEADER, true); curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'HEAD'); ob_start(); curl_exec($ch); var_dump(ob_get_clean()); phpinfo() tels me that I'm running: libcurl/7.10.5 OpenSSL/0.9.7b zlib/1.1.4 I've also seen bug #15279, but it was marked as documentation problem, and didn't explain this weird issue. Reproduce code: --------------- $ch = curl_init('http://beccati.com/img/adv.png'); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_HEADER, true); curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'HEAD'); var_dump(curl_exec($ch)); Expected result: ---------------- string(214) "HTTP/1.1 200 OK Date: Sat, 21 Feb 2004 07:39:06 GMT Server: Apache Last-Modified: Wed, 06 Aug 2003 12:35:16 GMT ETag: "27c64-204-3f30f604" Accept-Ranges: bytes Content-Length: 516 Content-Type: image/png " Actual result: -------------- bool(false) -- Edit bug report at http://bugs.php.net/?id=27341&edit=1 -- Try a CVS snapshot (php4): http://bugs.php.net/fix.php?id=27341&r=trysnapshot4 Try a CVS snapshot (php5): http://bugs.php.net/fix.php?id=27341&r=trysnapshot5 Fixed in CVS: http://bugs.php.net/fix.php?id=27341&r=fixedcvs Fixed in release: http://bugs.php.net/fix.php?id=27341&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=27341&r=needtrace Need Reproduce Script: http://bugs.php.net/fix.php?id=27341&r=needscript Try newer version: http://bugs.php.net/fix.php?id=27341&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=27341&r=support Expected behavior: http://bugs.php.net/fix.php?id=27341&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=27341&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=27341&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=27341&r=globals PHP 3 support discontinued: http://bugs.php.net/fix.php?id=27341&r=php3 Daylight Savings: http://bugs.php.net/fix.php?id=27341&r=dst IIS Stability: http://bugs.php.net/fix.php?id=27341&r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=27341&r=gnused Floating point limitations: http://bugs.php.net/fix.php?id=27341&r=float