Skip to content

Commit

Permalink
[HttpFoundation] added a way to retrieve raw body from a request
Browse files Browse the repository at this point in the history
  • Loading branch information
fabpot committed Dec 12, 2010
1 parent 5857576 commit a7c8157
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions src/Symfony/Component/HttpFoundation/Request.php
Expand Up @@ -56,6 +56,7 @@ class Request
*/
public $headers;

protected $content;
protected $languages;
protected $charsets;
protected $acceptableContentTypes;
Expand Down Expand Up @@ -106,6 +107,7 @@ public function initialize(array $query = null, array $request = null, array $at
$this->server = new ParameterBag(null !== $server ? $server : $_SERVER);
$this->headers = new HeaderBag($this->initializeHeaders());

$this->content = null;
$this->languages = null;
$this->charsets = null;
$this->acceptableContentTypes = null;
Expand Down Expand Up @@ -604,6 +606,20 @@ public function isMethodSafe()
return in_array($this->getMethod(), array('GET', 'HEAD'));
}

/**
* Return the request body content.
*
* @return string The request body content.
*/
public function getContent()
{
if (null === $this->content) {
$this->content = file_get_contents('php://input');
}

return $this->content;
}

public function getETags()
{
return preg_split('/\s*,\s*/', $this->headers->get('if_none_match'), null, PREG_SPLIT_NO_EMPTY);
Expand Down

0 comments on commit a7c8157

Please sign in to comment.