|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #49781 stream_get_meta_data seeks past http headers
Submitted: 2009-10-05 19:59 UTC Modified: 2009-10-14 01:00 UTC
From: marques at displague dot com Assigned:
Status: No Feedback Package: Streams related
PHP Version: 5.2.11 OS: linux
Private report: No CVE-ID: None
Have you experienced this issue?
Rate the importance of this bug to you:

 [2009-10-05 19:59 UTC] marques at displague dot com
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.


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2009-10-06 11:20 UTC]
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-06 13:13 UTC] 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 14:49 UTC]
Please try using this snapshot:
For Windows:

"bad dechunker" ? IIRC, something related was fixed already.
 [2009-10-14 01:00 UTC] php-bugs at lists dot php dot net
No feedback was provided for this bug for over a week, so it is
being suspended automatically. If you are able to provide the
information that was originally requested, please do so and change
the status of the bug back to "Open".
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu May 30 07:01:30 2024 UTC