#49781 [Opn->Fbk]: stream_get_meta_data seeks past http headers
| From: | jani@php.net | Date: | Tue, 06 Oct 2009 14:49:40 +0000 |
| Subject: | #49781 [Opn->Fbk]: stream_get_meta_data seeks past http headers | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-143322@lists.php.net to get a copy of this message | ||
ID: 49781
Updated by: jani@php.net
Reported By: marques at displague dot com
-Status: Open
+Status: Feedback
Bug Type: Streams related
Operating System: linux
PHP Version: 5.2.11
New Comment:
Please try using this snapshot:
http://snaps.php.net/php5.3-latest.tar.gz
For Windows:
http://windows.php.net/snapshots/
"bad dechunker" ? IIRC, something related was fixed already.
Previous Comments:
------------------------------------------------------------------------
[2009-10-06 13:13:11] marques at displague dot com
I missed this in stream_filter_prepend(), which explains the problem:
Note: Stream data is read from resources (both local and remote) in
chunks, with any unconsumed data kept in internal buffers. When a new
filter is prepended to a stream, data in the internal buffers, which
has already been processed through other filters will not be
reprocessed through the new filter at that time. This differs from the
behavior of stream_filter_append().
This behavior and the non-existence of a stream_filter_unregister()
function, means that I can't code a replacement for the bad dechunker
in PHP 5.3.0.
------------------------------------------------------------------------
[2009-10-06 11:20:07] sjoerd@php.net
Thank you for this bug report. To properly diagnose the problem, we
need a short but complete example script to be able to reproduce
this bug ourselves.
A proper reproducing script starts with <?php and ends with ?>,
is max. 10-20 lines long and does not require any external
resources such as databases, etc. If the script requires a
database to demonstrate the issue, please make sure it creates
all necessary tables, stored procedures etc.
Please avoid embedding huge scripts into the report.
------------------------------------------------------------------------
[2009-10-05 19:59:08] marques at displague dot com
Description:
------------
stream_get_meta_data will set the seek pointer in the buffer to some
point past the headers. The result is that if you want to use
stream_filter_prepend or stream_filter_append (after examining the meta
data) your first bucket will contain data after the meta data (HTTP
headers) and some of the initial content.
While trying to implement a chunked stream filter for PHP < 5.3.1 I
experienced this. The first bucket begins just after the hex chunklen
of the second chunk. Switching to an fgets() loop on the headers (and
stopping at the first empty line) corrects this.
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=49781&edit=1