webman升级到最新版本,请求发现每次请求的Request对象都是同一个
1.每次返回spl_object_hash都是同一个
2.每次获取到的对象值没有重置,假如说我第一次请求 username=test,setGet后username=hello_test,
但是下次请求的时候,我还是传递username=test,但是我通过方法获取到username直接就是hello_test,好像是个单例,没有重置一样,记住了上次的值
public function test(Request $request)
{
$username = $request->get('username');
$prefix = 'hello_';
$username = $prefix . $username;
$request->setGet('username', $username);
$error = null;
$retData = [
'username' => $request->get('username'),
'spl_object_hash' => spl_object_hash($request),
];
return $this->jsonReturn($this->_channel, $error, $retData);
}
乌班图系统
webman最新版本
发问题一定记得发下workerman 和webman具体版本。
哦哦,不好意思
环境:
workerman版本号:5.1.0
webman版本号:2.1.1
php环境:8.3.17
尝试解决:
2.我尝试在 workerman\Protocols\Http.php里面的input和decode方法上进行输出,想看看到底请求进来没(按道理来说,每次http请求应该都会进入到这个Http.php里面进行处理吧?),但是奇怪的是,多次请求,参数相同,只输出了2次日志信息,后续请求就没信息输出。感觉像是只要请求参数一样,请求超过2次,就不会走Http.php执行解析了。
3.我在 action里面打印了 Request对象的spl_object_hash,每次获取的都一样,像是一个单例。
spl_object_hash 返回同一个值,不一定代表是同一个对象。一个对象销毁后它的spl_object_hash值可能会被复用。
你的测试我没看懂,按照你的代码,下次请求的时候,还是传递username=test,$request->setGet('username', $username);还是被执行,得到hello_test没问题
可能表达的有问题。
假如我第一次请求 传递 username=test,获取到 username是test,返回 hello_test.
假如我第二次请求 传递 username=test,,获取到 username是hello_test,返回 hello_hello_test
假如我第三次请求 传递 username=test,获取到username是hello_hello_test,返回 hello_hello_hello_test
就是每次的请求把上次的值带过来了,append上了,
你windows没问题,那么linux上代码和windows是一套么,workerman和webman版本是否一致都是最新的?
还有测试的是什么客户端,浏览器还是什么?
composer info | grep workerman
发下
workerman/coroutine 1.1.3 Workerman coroutine
workerman/webman-framework 2.1.1 High performance HTTP Service Frame...
workerman/workerman 5.1.0 An asynchronous event driven PHP fr..
使用的是谷歌浏览器。
弄个能测试出问题的项目打包发到 QQ邮箱 2202055656
收到
升级下
composer requrie workerman/webman-framework ^2.1.2
试下收到,好的
直接修改request对象了吧,不要用setGet
是的,直接修改的。。然后就有这个问题了。 你这边有遇到了吗?
用了setGet就和你这一样啦,首页有个一样的问题 https://www.workerman.net/q/13916
好的,但是感觉不科学,每次的请求不应该是个新的Request对象吗?为什么会有这种问题
是不是访问的http server进程对应的eventloop配置为空?
是的,但是我看,默认是select模型