philsturgeon/codeigniter-restserver — Issue #91: post() reads from input->post() when passed a key
Author: doginthehat
Created: 2012-02-12 09:57:22+00:00
State: open

Came across this trying to debug an app..

in the controller's post($key, $xss_clean) method (line 645), the function returns the _post_args if no key is requested, but if you do pass a key to the function, then it suddenly read off from the input->post() function.

This doesn't work in all cases. E.g. I'm using backbone, which sends data as json encoded in the body of the request. This doesn't set the $_POST variables which input->post() reads from.

Seems like an oversight, the other methods work fine.. In my case changing the post function's code to this works well:

```
public function post($key = NULL, $xss_clean = TRUE)
{
if ($key === NULL)
{
return $this->_post_args;
}

return array_key_exists($key, $this->_post_args) ? $this->_xss_clean($this->_post_args[$key], $xss_clean) : FALSE;
}
```