国产+高潮+在线,国产 av 仑乱内谢,www国产亚洲精品久久,51国产偷自视频区视频,成人午夜精品网站在线观看

webman新版本Request沒有每次請求都是新的

huazai

問題描述

webman升級到最新版本,請求發(fā)現(xiàn)每次請求的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);
     }

重現(xiàn)問題的步驟

操作系統(tǒng)環(huán)境及workerman/webman等具體版本

烏班圖系統(tǒng)
webman最新版本

654 3 0
3個回答

walkor 打賞

發(fā)問題一定記得發(fā)下workerman 和webman具體版本。

  • huazai 2025-03-10

    哦哦,不好意思

    環(huán)境:
    workerman版本號:5.1.0
    webman版本號:2.1.1
    php環(huán)境:8.3.17

    嘗試解決:

    1. window下沒問題,但是在烏班圖系統(tǒng)上有問題。
      2.我嘗試在 workerman\Protocols\Http.php里面的input和decode方法上進行輸出,想看看到底請求進來沒(按道理來說,每次http請求應該都會進入到這個Http.php里面進行處理吧?),但是奇怪的是,多次請求,參數(shù)相同,只輸出了2次日志信息,后續(xù)請求就沒信息輸出。感覺像是只要請求參數(shù)一樣,請求超過2次,就不會走Http.php執(zhí)行解析了。
      3.我在 action里面打印了 Request對象的spl_object_hash,每次獲取的都一樣,像是一個單例。
    2. Webman\Http__clone方法,我添加了輸出日志,但是就前2次輸出了,后面好像就沒有被調(diào)用。
  • walkor 2025-03-10

    spl_object_hash 返回同一個值,不一定代表是同一個對象。一個對象銷毀后它的spl_object_hash值可能會被復用。
    你的測試我沒看懂,按照你的代碼,下次請求的時候,還是傳遞username=test,$request->setGet('username', $username);還是被執(zhí)行,得到hello_test沒問題

  • huazai 2025-03-10

    可能表達的有問題。
    假如我第一次請求 傳遞 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上了,

  • walkor 2025-03-10

    你windows沒問題,那么linux上代碼和windows是一套么,workerman和webman版本是否一致都是最新的?

  • walkor 2025-03-10

    還有測試的是什么客戶端,瀏覽器還是什么?

  • walkor 2025-03-10

    composer info | grep workerman
    發(fā)下

  • huazai 2025-03-10

    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..

  • huazai 2025-03-10

    使用的是谷歌瀏覽器。

  • walkor 2025-03-10

    弄個能測試出問題的項目打包發(fā)到 QQ郵箱 2202055656

  • huazai 2025-03-10

    收到

  • walkor 2025-03-10

    升級下 composer requrie workerman/webman-framework ^2.1.2 試下

  • huazai 2025-03-10

    收到,好的

lunzi

直接修改request對象了吧,不要用setGet

  • huazai 2025-03-10

    是的,直接修改的。。然后就有這個問題了。 你這邊有遇到了嗎?

  • lunzi 2025-03-10

    用了setGet就和你這一樣啦,首頁有個一樣的問題 http://www.wtbis.cn/q/13916

  • huazai 2025-03-10

    好的,但是感覺不科學,每次的請求不應該是個新的Request對象嗎?為什么會有這種問題

artisan

是不是訪問的http server進程對應的eventloop配置為空?

  • huazai 2025-03-10

    是的,但是我看,默認是select模型

??