-
-
Notifications
You must be signed in to change notification settings - Fork 318
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
yar扩展无法在基于swoole环境的框架中使用 #150
Comments
这是说Header已经被发送过了,或者之前已经有输出了,不确定是否是Swoole会默认输出什么东西? |
PHP_METHOD(yar_server, handle)
{
if (SG(headers_sent)) {
php_error_docref(NULL, E_WARNING, "headers already has been sent");
RETURN_FALSE; @matyhtf 有没有可能swoole在一个请求结束后,没有重置这个SG(headers_sent)标志? |
@laruence 由于 swoole 是并发服务器,没有 在 swoole 中也无法使用 PHP 的 想不到太好的解决办法,这里应该有好几个地方不兼容。 <?php
$http = new swoole_http_server("127.0.0.1", 9501);
$http->on("start", function ($server) {
echo "Swoole http server is started at http://127.0.0.1:9501 \n";
});
$http->on("request", function ($request, $response) {
$response->header("Content-Type", "text/plain");
$response->cookie("test", "value", time() + 3600);
var_dump($requset->get, $requset->post, $request->cookie);
$response->end("Hello World\n");
});
$http->start(); |
如果要兼容 swoole 或者 workerman 这样的服务器,yar 需要提供设置自定义 header、setcookie 的 API |
hmm, 看起来没那么简单,不过在swoole场景下,还要yar干嘛呢?或者就不http了? |
本次测试基于 swoole 环境运行的 hyperf 框架。 以下相同的代码,在 Laravel 框架中测试一切OK
3.客户端调用代码
报错代码
The text was updated successfully, but these errors were encountered: