lithium\net\http\Response::body PHP Method

body() public method

Add data to or compile and return the HTTP message body, optionally decoding its parts according to content type.
See also: lithium\net\Message::body()
See also: lithium\net\http\Message::_decode()
public body ( mixed $data = null, array $options = [] ) : array
$data mixed
$options array - `'buffer'` _integer_: split the body string - `'encode'` _boolean_: encode the body based on the content type - `'decode'` _boolean_: decode the body based on the content type
return array
    public function body($data = null, $options = array())
    {
        $defaults = array('decode' => true);
        return parent::body($data, $options + $defaults);
    }

Usage Example

 public function send($method, $path = null, $data = array(), $options = array())
 {
     $defaults = array('return' => 'body', 'type' => 'form');
     $options += $defaults;
     $request = $this->_request($method, $path, $data, $options);
     $response = new Response();
     $response->body = json_encode(array('ok' => true, 'id' => '12345', 'rev' => '1-2', 'body' => 'something'));
     $this->last = (object) compact('request', 'response');
     return $options['return'] == 'body' ? $response->body() : $response;
 }
All Usage Examples Of lithium\net\http\Response::body