@@ -224,20 +224,24 @@ replace all possibly existing uploaded files::
224
224
PUT, PATCH or DELETE Data
225
225
-------------------------
226
226
227
- .. php :method :: input($callback, [$options] )
227
+ .. php :method :: getBody( )
228
228
229
229
When building REST services, you often accept request data on ``PUT `` and
230
230
``DELETE `` requests. Any ``application/x-www-form-urlencoded `` request body data
231
- will automatically be parsed and set to ``$this->data `` for ``PUT `` and
232
- ``DELETE `` requests. If you are accepting JSON or XML data, see below for how
233
- you can access those request bodies.
231
+ will automatically be parsed and available via ``$request->getData() `` for ``PUT `` and
232
+ ``DELETE `` requests. If you are accepting JSON or XML data, you can
233
+ access the raw data with `` getBody() ``::
234
234
235
- When accessing the input data, you can decode it with an optional function.
236
- This is useful when interacting with XML or JSON request body content.
237
- Additional parameters for the decoding function can be passed as arguments to
238
- ``input() ``::
235
+ // Get the stream wrapper on the request body
236
+ $body = $request->getBody();
239
237
240
- $jsonData = $this->request->input('json_decode');
238
+ // Get the request body as a string
239
+ $bodyString = (string)$request->getBody();
240
+
241
+ If your requests contain XML or JSON request content, you should consider using
242
+ :ref: `body-parser-middleware ` to have CakePHP automatically parse those content
243
+ types making the parsed data available in ``$request->getData() `` and
244
+ ``$request->getParsedBody() ``.
241
245
242
246
Environment Variables (from $_SERVER and $_ENV)
243
247
-----------------------------------------------
@@ -394,7 +398,7 @@ There are several built-in detectors that you can use:
394
398
X-Requested-With = XMLHttpRequest.
395
399
* ``is('ssl') `` Check to see whether the request is via SSL.
396
400
* ``is('flash') `` Check to see whether the request has a User-Agent of Flash.
397
- * ``is('json') `` Check to see whether the request URL has 'json' extension or the
401
+ * ``is('json') `` Check to see whether the request URL has 'json' extension or the
398
402
`Accept ` header is set to 'application/json'.
399
403
* ``is('xml') `` Check to see whether the request URL has 'xml' extension or the `Accept ` header is set to
400
404
'application/xml' or 'text/xml'.
0 commit comments