workerman4.1 header location

showx

workerman 3.x可以使用
Workerman\Protocols\Http::header('Location: .....');
这个函数作为跳转网站
workerman 4.1要怎么实现以上的功能呢?

2257 1 0
1个回答

six
use Workerman\Worker;
use Workerman\Protocols\Http\Response;
require_once './Workerman/Autoloader.php';

$worker = new Worker('http://0.0.0.0:8080');

$worker->onMessage = function($connection, $request)
{
    $response = new Response(302, ['Location' => $location]);
    $connection->send($response);
};

// 运行worker
Worker::runAll();

试下

年代过于久远,无法发表回答
×
🔝