内容简介:v4.6.2 版本主要是一个 Bug 修复版本,没有向下不兼容改动。 新增了 Coroutine\Socket->recvLine() 和 Coroutine\Socket->readWithBuffer() 方法 分别用于解决 socket_read 兼容性问题和使用 recv(1) 逐字节接收时...
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在 PHP 8 下 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)
以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持 码农网
猜你喜欢:- fastjson 1.2.55 版本发布,Bug 修复版本
- Swoole v4.6.1 版本发布,Bug 修复版本
- Swoole v4.6.4 版本发布,Bug 修复版本
- Swoole v4.6.7 版本发布,Bug 修复版本
- fastjson 1.2.57 版本发布,Bug 修复维护版本
- Swoole v4.5.11 版本发布,Bug 修复版本
本站部分资源来源于网络,本站转载出于传递更多信息之目的,版权归原作者或者来源机构所有,如转载稿涉及版权问题,请联系我们。
Machine Learning in Action
Peter Harrington / Manning Publications / 2012-4-19 / GBP 29.99
It's been said that data is the new "dirt"—the raw material from which and on which you build the structures of the modern world. And like dirt, data can seem like a limitless, undifferentiated mass. ......一起来看看 《Machine Learning in Action》 这本书的介绍吧!