mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2025-09-05 02:52:41 +00:00
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:
parent
0be0b0ede0
commit
512e570202
3 changed files with 106 additions and 34 deletions
|
@ -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;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue