I have a RESTful Zend action which should send me back a json encoded object, but in the response whatever I set in the body gets duplicated.
My code looks like this :
public function blablaAction() {
$this->_helper->viewRenderer->setNoRender();
$response = $this->getResponse();
[...]
$response->setBody('aaaaaaaa' . json_encode($output) . 'aaaaaaaa');
$response->sendResponse();
}
And if I look at the response body, I can see:
aaaaaaaaXXXXXXXXXXXXXXaaaaaaaaaaaaaaaaXXXXXXXXXXXXXXaaaaaaaa
(XXXXXXXXXXXXXX
being the json encoded data).
Why?
PS: I added the aaaaaaa
just to make sure the problem didn't come from the json encoding. I'll just have $response->setBody(json_encode($output));
when it finally works as expected.