body() public method

Compile the HTTP message body, optionally encoding its parts according to content type.
See also: lithium\net\http\Message::body()
See also: lithium\net\http\Message::_encode()
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
Beispiel #1
0
 public function testConstruct()
 {
     $request = new Request(array('host' => 'localhost', 'port' => 443, 'headers' => array('Header' => 'Value'), 'body' => array('Part 1'), 'params' => array('param' => 'value')));
     $expected = 'localhost';
     $result = $request->host;
     $this->assertEqual($expected, $result);
     $expected = 443;
     $result = $request->port;
     $this->assertEqual($expected, $result);
     $expected = 'GET';
     $result = $request->method;
     $this->assertEqual($expected, $result);
     $expected = 'HTTP/1.1';
     $result = $request->protocol;
     $this->assertEqual($expected, $result);
     $expected = '1.1';
     $result = $request->version;
     $this->assertEqual($expected, $result);
     $expected = '/';
     $result = $request->path;
     $this->assertEqual($expected, $result);
     $expected = array('param' => 'value');
     $result = $request->params;
     $this->assertEqual($expected, $result);
     $expected = array('Host: localhost:443', 'Connection: Close', 'User-Agent: Mozilla/5.0', 'Header: Value');
     $result = $request->headers();
     $this->assertEqual($expected, $result);
     $expected = array();
     $result = $request->cookies;
     $this->assertEqual($expected, $result);
     $expected = 'Part 1';
     $result = $request->body();
     $this->assertEqual($expected, $result);
 }
Beispiel #2
0
 public function body($data = null, $options = array())
 {
     $defaults = array('encode' => false);
     return parent::body($data, $options + $defaults);
 }