Voting

: one plus one?
(Example: nine)

The Note You're Voting On

php at rapsys dot eu
11 years ago
Here is a snippet to read compressed raw post data without enabling global variables.

I needed it to read xml posted data submitted by ocs agent. The data was sent as Content-Type: application/x-compressed (zlib compressed data).

It seems related to an old bug which still seems broken :
https://bugs.php.net/bug.php?id=49411

The important part is the default window set to 15 instead of -15.

Code snippet
<?php
$data
= '';
$fh = fopen('php://input', 'rb');
stream_filter_append($fh, 'zlib.inflate', STREAM_FILTER_READ, array('window'=>15));
while(!
feof($fh)) {
$data .= fread($fh, 8192);
}
?>

<< Back to user notes page

To Top