From: a...@php.net Operating system: Irrelevant PHP version: 5.2.8 PHP Bug Type: cURL related Bug description: Missing support for CURLOPT_IOCTLFUNCTION
Description: ------------ PHP's cURL extension allows using a callback for reading the request body via CURLOPT_READFUNCTION, but it doesn't provide a way to set a CURLOPT_IOCTLFUNCTION callback for rewinding the request body. This rewinding may be needed when doing a POST or PUT HTTP request to resource protected by Digest authentication. Reproduce code: --------------- <?php $position = 0; $data = 'foo=' . str_repeat('bar', 10000); function read_callback($ch, $fd, $length) { global $position, $data; if ($position >= strlen($data)) { return ''; } $string = substr($data, $position, $length); $position += strlen($string); return $string; } $ch = curl_init(); curl_setopt($ch, CURLOPT_POST, true); // This should be some URL protected by HTTP digest auth! curl_setopt($ch, CURLOPT_URL, 'http://www.example.com/digest/'); curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_DIGEST); curl_setopt($ch, CURLOPT_USERPWD, 'user:password'); curl_setopt($ch, CURLOPT_READFUNCTION, 'read_callback'); curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Length: ' . strlen($data))); if (!curl_exec($ch)) { echo 'Error #' . curl_errno($ch) . ': ' . curl_error($ch); } ?> Expected result: ---------------- Request should proceed. Actual result: -------------- Error #65: necessary data rewind wasn't possible -- Edit bug report at http://bugs.php.net/?id=47204&edit=1 -- Try a CVS snapshot (PHP 5.2): http://bugs.php.net/fix.php?id=47204&r=trysnapshot52 Try a CVS snapshot (PHP 5.3): http://bugs.php.net/fix.php?id=47204&r=trysnapshot53 Try a CVS snapshot (PHP 6.0): http://bugs.php.net/fix.php?id=47204&r=trysnapshot60 Fixed in CVS: http://bugs.php.net/fix.php?id=47204&r=fixedcvs Fixed in CVS and need be documented: http://bugs.php.net/fix.php?id=47204&r=needdocs Fixed in release: http://bugs.php.net/fix.php?id=47204&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=47204&r=needtrace Need Reproduce Script: http://bugs.php.net/fix.php?id=47204&r=needscript Try newer version: http://bugs.php.net/fix.php?id=47204&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=47204&r=support Expected behavior: http://bugs.php.net/fix.php?id=47204&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=47204&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=47204&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=47204&r=globals PHP 4 support discontinued: http://bugs.php.net/fix.php?id=47204&r=php4 Daylight Savings: http://bugs.php.net/fix.php?id=47204&r=dst IIS Stability: http://bugs.php.net/fix.php?id=47204&r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=47204&r=gnused Floating point limitations: http://bugs.php.net/fix.php?id=47204&r=float No Zend Extensions: http://bugs.php.net/fix.php?id=47204&r=nozend MySQL Configuration Error: http://bugs.php.net/fix.php?id=47204&r=mysqlcfg