Adding ability to map arbitrary content types and decoding methods to RequestHandlerComponent.

Removing hardcoded XML decoding, but continuing to provide the functionality.
Adding default support for JSON decoding.
Fixing stdin/input mixup.
Fixes #716
This commit is contained in:
mark_story 2011-05-01 09:59:47 -04:00
parent 0be0b0ede0
commit 512e570202
3 changed files with 106 additions and 34 deletions

View file

@ -106,6 +106,15 @@ class CakeRequest implements ArrayAccess {
'webOS', 'Windows CE', 'Xiino'
))
);
/**
* Copy of php://input. Since this stream can only be read once in most SAPI's
* keep a copy of it so users don't need to know about that detail.
*
* @var string
*/
private $__input = '';
/**
* Constructor
*
@ -708,11 +717,13 @@ class CakeRequest implements ArrayAccess {
* @return string contents of stdin
*/
protected function _readStdin() {
$fh = fopen('php://stdin', 'r');
rewind($fh);
$content = stream_get_contents($fh);
fclose($fh);
return $content;
if (empty($this->__input)) {
$fh = fopen('php://input', 'r');
$content = stream_get_contents($fh);
fclose($fh);
$this->__input = $content;
}
return $this->__input;
}
/**