Swoole v4.6.2バージョンがリリースされ、バグ修正バージョン

v4.6.2 バージョンは主にバグ修正バージョンであり、下位互換性のない変更はありません。

追加さ Coroutine\Socket->recvLine() れた Coroutine\Socket->readWithBuffer() メソッド

これらは 、バイトごとの受信 を使用する場合の、socket_readの互換性の問題および recv(1)多数のシステムコールの問題を解決するために使用され ます。

同時に、このResponse\create() メソッドは拡張され 、次のようにサーバーとは独立して使用できます。

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() 方法、サーバーとは独立して使用できます(#3998)(@ matyhtf)
  • Coroutine\Redis->hExists 互換モードを設定した後のブール型の戻りをサポート (swoole / swoole-src @ b8cce7c)(@ matyhtf)
  • socket_read PHP_NORMAL_READオプションの設定をサポート (swoole / swoole-src @ b1a0dcc)(@ matyhtf)

修復

  • 修正 Coroutine::defer PHP8(#3997)(@huanghantao)の下でコアダンプ問題を
  • スレッドコンテキストを使用するときCoroutine\Socket::errCode の誤った設定の問題を修正しまし た(swoole / swoole-src @ 004d08a)(@ matyhtf)
  • 最新のmacos(#4007)(@ matyhtf)でSwooleのコンパイルが失敗する問題を修正します
  • md5_fileパラメーターがURLに渡されたときにphpストリームコンテキストがnullポインターになる問題を修正しました(#4016)(@ ZhiyangLeeCN)

カーネル

  • AIOスレッドプールを使用してstdioをフックします(以前はstdioをソケットとして扱うことによって引き起こされたマルチコルーチンの読み取りと書き込みの問題を解決します)(#4002)(@ matyhtf)
  • HttpContextのリファクタリング(#3998)(@ matyhtf)
  • リファクタリング Process::wait() (#4019)(@ matyhtf)

おすすめ

転載: www.oschina.net/news/127801/swoole-4-6-2-released