Page MenuHomePhabricator

Fix HTTP body decompression in PHP 5.6
ClosedPublic

Authored by epriestley on Feb 20 2016, 7:55 PM.
Tags
None
Referenced Files
F14315564: D15314.id36939.diff
Wed, Dec 18, 6:20 AM
F14309801: D15314.id.diff
Wed, Dec 18, 1:10 AM
F14309799: D15314.diff
Wed, Dec 18, 1:10 AM
Unknown Object (File)
Thu, Dec 12, 5:58 AM
Unknown Object (File)
Sun, Dec 8, 12:28 AM
Unknown Object (File)
Fri, Dec 6, 4:28 PM
Unknown Object (File)
Fri, Dec 6, 12:06 AM
Unknown Object (File)
Tue, Dec 3, 9:14 PM
Subscribers
None

Details

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.

Diff Detail

Repository
rP Phabricator
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

epriestley retitled this revision from to Fix HTTP body decompression in PHP 5.6.
epriestley updated this object.
epriestley edited the test plan for this revision. (Show Details)
epriestley added a reviewer: chad.
chad edited edge metadata.
This revision is now accepted and ready to land.Feb 20 2016, 9:47 PM
This revision was automatically updated to reflect the committed changes.