gpt4 book ai didi

http - 响应中格式错误的 block

转载 作者:塔克拉玛干 更新时间:2023-11-01 19:09:43 25 4
gpt4 key购买 nike

我的简单 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;
}

给我一个格式错误的分块响应。例如在 java 中:

org.apache.http.MalformedChunkCodingException: Chunked stream ended unexpectedly

Chrome 拒绝显示响应,在 Firefox 中我可以看到响应并且 Fiddler2 检测到响应存在畸形。

编辑:

还试过:

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;
}

还是一样的问题。这有可能与 Apache 有关吗?还是 Symfony2 配置?

最佳答案

尝试使用 JsonResponse 对象。我知道它应该是一样的”,但我在 Firefox 中看到了一些差异......

关于http - 响应中格式错误的 block ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20331007/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com