Reputation: 450
My simple controller:
class GeofencesController extends Controller
{
public function indexAction()
{
$json = '[
{
"id": 123,
"name": "muh",
"latitude": 32.121456,
"longitude": -19.238573,
"radius": 500
},
{
"id": 532,
"name": "blah",
"latitude": 32.121456,
"longitude": -19.238573,
"radius": 100
},
{
"id": 720,
"name": "bleh",
"latitude": 32.121456,
"longitude": -19.238573,
"radius": 200
}
]
';
$json = json_decode($json, true);
$response = new Response();
$response->setContent(json_encode($json));
$response->headers->set('Content-Type', 'application/json');
return $response;
}
is giving me a malformed chunked response. For example in java:
org.apache.http.MalformedChunkCodingException: Chunked stream ended unexpectedly
Chrome refuses to show the response, in Firefox i can see the response and Fiddler2 detects there is a Malformation with the response.
EDIT:
Also tried:
class GeofencesController extends Controller
{
public function indexAction()
{
$json = '[{"id": 123,"name": "bleh","latitude": 32.121456,"longitude": -19.238573,"radius": 500}]';
$json = json_decode($json, true);
$response = new JsonResponse($json);
return $response;
}
and still same problem. Is there a possibility this is related to Apache? Or Symfony2 config?
Upvotes: 1
Views: 1142
Reputation: 20191
Try using JsonResponse
object. I know it's supposed to be same" but I have seen some difference in Firefox...
Upvotes: 1