目前默認(rèn)的是 Content-Type: text/html;charset=utf-8 ,如何修改為 application/json
// 監(jiān)聽(tīng)一個(gè)http端口
$inner_http_worker = new Worker($httpWorkUrl);
// 當(dāng)http客戶端發(fā)來(lái)數(shù)據(jù)時(shí)觸發(fā)
$inner_http_worker->onMessage = function ($http_connection, $data) {
$http_connection->setHeader('Content-Type', 'application/json');
return $http_connection->send($data);
}
但是沒(méi)有效果
剛自己解決了,要感謝@six給了方向
\Workerman\Protocols\Http::header('Content-Type:application/json; charset=utf-8');
return $http_connection->send($data);