关于php:Swoole-v462-版本发布Bug-修复版本

3次阅读

共计 1834 个字符,预计需要花费 5 分钟才能阅读完成。

v4.6.2 版本次要是一个 Bug 修复版本,没有向下不兼容改变。

新增了 Coroutine\Socket->recvLine()Coroutine\Socket->readWithBuffer() 办法

别离用于解决 socket_read 兼容性问题和应用 recv(1) 逐字节接管时产生大量零碎调用问题

同时加强了 Response\create() 办法,能够独立于 Server 应用,如:

use Swoole\Coroutine\Server;
use Swoole\Coroutine\Server\Connection;
use Swoole\Http\Request;
use Swoole\Http\Response;

Swoole\Coroutine\run(function () {$server = new Server('0.0.0.0', 9501, false);

    go(function () use ($server) {$server->handle(function (Connection $conn) use ($server) {$req = Request::create();
            while(true) {$data = $conn->recv();
                if (strlen($data) != $req->parse($data) or $req->isCompleted()) {break;}
            }
            var_dump($req->get);
            $resp = Response::create([$conn->exportSocket(), $req]);
            $resp->header('X-Server', 'swoole');
            $resp->end('Hello, Swoole');

            $server->shutdown();});
        $server->start();});
});

启动后应用 curl 发动申请

$ curl -I http://127.0.0.1:9501/\?hello\=swoole
HTTP/1.1 200 OK
X-Server: swoole
Server: swoole-http-server
Connection: keep-alive
Content-Type: text/html
Date: Mon, 25 Jan 2021 10:58:31 GMT
Content-Length: 13

$ curl http://127.0.0.1:9501/\?hello\=swoole
Hello, Swoole

而终端会打印申请中的 GET 参数

array(1) {["hello"]=>
  string(6) "swoole"
}

上面是残缺的更新日志:

新增 API

  • 新增 Http\Request\getMethod() 办法 (#3987) (@luolaifa000)
  • 新增 Coroutine\Socket->recvLine() 办法 (#4014) (@matyhtf)
  • 新增 Coroutine\Socket->readWithBuffer() 办法 (#4017) (@matyhtf)

加强

  • 加强 Response\create() 办法,能够独立于 Server 应用 (#3998) (@matyhtf)
  • 反对 Coroutine\Redis->hExists 在设置了 compatibility_mode 之后返回 bool 类型 (swoole/swoole-src@b8cce7c) (@matyhtf)
  • 反对 socket_read 设置 PHP_NORMAL_READ 选项 (swoole/swoole-src@b1a0dcc) (@matyhtf)

修复

  • 修复 Coroutine::defer 在 PHP8 下 coredump 的问题 (#3997) (@huanghantao)
  • 修复当应用 thread context 的时候,谬误设置 Coroutine\Socket::errCode 的问题 (swoole/swoole-src@004d08a) (@matyhtf)
  • 修复在最新的 macos 下 Swoole 编译失败的问题 (#4007) (@matyhtf)
  • 修复当 md5_file 参数传入 url 导致 php stream context 为空指针的问题 (#4016) (@ZhiyangLeeCN)

内核

  • 应用 AIO 线程池 hook stdio(解决之前把 stdio 视为 socket 导致的多协程读写问题)(#4002) (@matyhtf)
  • 重构 HttpContext (#3998) (@matyhtf)
  • 重构 Process::wait() (#4019) (@matyhtf)

正文完
 0