From: [EMAIL PROTECTED] Operating system: Linux, debian PHP version: 5.2.6 PHP Bug Type: Streams related Bug description: file_get_contents() gives "stream does not support seeking" error with offset
Description: ------------ file_get_contents() supports an offset. However, at certain times this gives an "stream does not support seeking" at a certain offset. This offset might differ with installations and the website a resource is requested from. Reproduce code: --------------- file_get_contents("http://stock.ter.dk/taske.jpg", null, null, 8000, 1000); Expected result: ---------------- The content should be returned Actual result: -------------- Warning: file_get_contents(): stream does not support seeking in Command line code on line 1 Warning: file_get_contents(): Failed to seek to position 8000 in the stream in Command line code on line 1 The exact cutoff-point seem to differ. A script such as the following gives different results at different servers. <?php $offset = 0; $length = 500; while ($file = file_get_contents("http://stock.ter.dk/taske.jpg", null, null, $offset, $length)) { print "$offset, $length\n"; $offset += $length; } ?> PHP 5.2.6-0.dotdeb.1 with Suhosin-Patch 0.9.6.2 (cli): 0, 500 500, 500 1000, 500 1500, 500 2000, 500 2500, 500 3000, 500 3500, 500 4000, 500 4500, 500 5000, 500 5500, 500 6000, 500 6500, 500 7000, 500 7500, 500 Warning: file_get_contents(): stream does not support seeking in /home/penguin/- on line 4 Warning: file_get_contents(): Failed to seek to position 8000 in the stream in /home/penguin/- on line 4 PHP 5.2.0 (cli) (built: Nov 26 2006 10:25:07): 0, 500 500, 500 1000, 500 Warning: file_get_contents(): stream does not support seeking in /home/penguin/- on line 4 Warning: file_get_contents(): Failed to seek to position 1500 in the stream. in /home/penguin/- on line 4 The behaviour is the same whether php-cli or mod_php is used, as seen at http://stock.ter.dk/filegetbug.php (as a side note, file_get_contents() [or rather, the http stream] could try to use a ranged request when an offset and range is present, with a fallback to the current behaviour if the webserver returns the whole file) -- Edit bug report at http://bugs.php.net/?id=46043&edit=1 -- Try a CVS snapshot (PHP 5.2): http://bugs.php.net/fix.php?id=46043&r=trysnapshot52 Try a CVS snapshot (PHP 5.3): http://bugs.php.net/fix.php?id=46043&r=trysnapshot53 Try a CVS snapshot (PHP 6.0): http://bugs.php.net/fix.php?id=46043&r=trysnapshot60 Fixed in CVS: http://bugs.php.net/fix.php?id=46043&r=fixedcvs Fixed in release: http://bugs.php.net/fix.php?id=46043&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=46043&r=needtrace Need Reproduce Script: http://bugs.php.net/fix.php?id=46043&r=needscript Try newer version: http://bugs.php.net/fix.php?id=46043&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=46043&r=support Expected behavior: http://bugs.php.net/fix.php?id=46043&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=46043&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=46043&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=46043&r=globals PHP 4 support discontinued: http://bugs.php.net/fix.php?id=46043&r=php4 Daylight Savings: http://bugs.php.net/fix.php?id=46043&r=dst IIS Stability: http://bugs.php.net/fix.php?id=46043&r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=46043&r=gnused Floating point limitations: http://bugs.php.net/fix.php?id=46043&r=float No Zend Extensions: http://bugs.php.net/fix.php?id=46043&r=nozend MySQL Configuration Error: http://bugs.php.net/fix.php?id=46043&r=mysqlcfg