简体   繁体   中英

Malformed chunk in response

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?

Try using JsonResponse object. I know it's supposed to be same" but I have seen some difference in Firefox...

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM