Clean up handling of PUT data.

See https://pear.php.net/bugs/bug.php?id=18431 and https://pear.php.net/bugs/bug.php?id=20106.

This handles the request body with a consistent API to the way request headers are handled. It should fix the bugs in both 18431 and 20106.