cphalcon
cphalcon copied to clipboard
Phalcon\Http\Response::setJsonContent does not set appropriate content type
Hello,
Could you please set the content type header to 'application/json' when using the Phalcon\Http\Response::setJsonContent() method? I feel like it is implied that if someone is setting the body of the response to JSON, the header should also be set appropriately. I feel the first snip below should equate to the second. Thanks in advance!
$returnObj = new \stdClass();
$returnObj->status = 'error';
$response = new \Phalcon\Http\Response();
$response->setJsonContent($returnObj);
$response->send();
vs:
$returnObj = new \stdClass();
$returnObj->status = 'error';
$response = new \Phalcon\Http\Response();
$response->setRawHeader("Content-Type: application/json; charset=utf-8");
$response->setContent(json_encode($returnObj));
$response->send();
Implemented in 2.1.x