Homec4science

Fix HTTP body decompression in PHP 5.6

Authored by epriestley <git@epriestley.com> on Feb 20 2016, 20:51.

Description

Fix HTTP body decompression in PHP 5.6

Summary:
Ref T10264. Under PHP 5.6, you are no longer allowed to use compress.zlib://php://input as an argument to either fopen() or file_get_contents().

Instead, open php://input as a file handle, then add zlib.inflate as a stream wrapper. This requires some level of magic to work properly.

Test Plan:
First, I constructed a synthetic gzipped payload by typing some words into a file and using gzcompress() to compress it.

Then I used a curl command like this to make requests with it:

$ curl -X POST -H "Content-Length: 66" -H "Content-Type: text/plain" -H "Content-Encoding: gzip" --data-binary @payload.deflate -v http://127.0.0.1/

I modified Phabricator to just dump the raw request body and exit, and reproduced the issue under PHP 5.6 (no body, error in log) by brining up a micro instance in EC2 and installing php56 on it.

After this patch, it dumped the body properly instead, and PHP 5.5 also continued worked properly.

Reviewers: chad

Reviewed By: chad

Maniphest Tasks: T10264

Differential Revision: https://secure.phabricator.com/D15314

Details

Committed
epriestley <git@epriestley.com>Feb 20 2016, 23:55
Pushed
aubortJan 31 2017, 17:16
Parents
rPH929b4ccb5cd2: Remove Similar Questions column from Ponder
Branches
Unknown
Tags
Unknown

Event Timeline

epriestley <git@epriestley.com> committed rPH42566379dc3c: Fix HTTP body decompression in PHP 5.6 (authored by epriestley <git@epriestley.com>).Feb 20 2016, 23:55