workerman/http-client响应乱码

岛屿可以找到海

程序代码或配置

public function test(){

    $http=new Client();
    $http->request($this->api_url, [
        'method' => 'POST',
        'headers' => ["Content-Type"=>"application/json",
            "Authorization"=>"Bearer ".$this->token,
            "Connection"=>"keep-alive",
            "Accept-Encoding"=>"gzip, deflate,br",
            "Accept"=>"*/*"],
        'data' => json_encode([
            "model"=>"gpt-3.5-turbo-0613",
            "messages"=>[
                [
                    'role' => 'system',
                    'content' => 'You are a helpful assistant.',
                ],
                [
                    'role' => 'user',
                    'content' => '你好',
                ]
            ],
            "temperature"=> 0.6
        ]),
        'success' => function ($response) {
            //echo $response->getBody();
            print_r((string)$response->getBody());

        },
        'error' => function ($exception) {
           // echo $exception;
        }
    ]);
}

重现问题的步骤


我对接chatgpt接口时chatgpt响应乱码,没使用流式返回,
但我测试自己写的接口数据是可以正常返回的,这就奇怪了

操作系统环境及workerman/webman等具体版本

Windows11
php7.4
workerman v4.1.13

314 1 0
1个回答

walkor

"Accept-Encoding"=>"gzip, deflate,br", 去掉

  • 暂无评论
🔝