swooletw / laravel-swoole

High performance HTTP server based on Swoole. Speed up your Laravel or Lumen applications.
MIT License
4.03k stars 388 forks source link

(我的英文不好)关于http服务终止输出能否做一些小修改 #525

Closed bdHeart closed 1 year ago

bdHeart commented 2 years ago

Make sure you read Issues Guideline and answer these questions before submitting your issue. Thanks! (Any non-English issues will be closed immediately.)

  1. Please provide your PHP and Swoole version. (php -v and php --ri swoole) PHP 7.4 Swoole 4.8.5

  2. Please provide your Laravel/Lumen version. Lumen 8.3.4

  3. Which release version of this package are you using? swooletw/laravel-swoole 2.11

  4. What did you do? If possible, provide a recipe for reproducing the error. 我希望在执行业务逻辑之前终止输出,比如在auth JWT中间件中输出json格式的“Token does not exist”的提示。我不能使用exit,因为这是禁止的;也不想使用throw,因为它不能让我输出想要的json格式。所以我希望禁止输出而使用了ob_end_flush()。

但是原包中SwooleTW\Http\Server\Sandbox line 242 行中有一句ob_end_clean()会造成错误。

  1. What did you expect to see? 能否将SwooleTW\Http\Server\Sandbox line 242 行中ob_end_clean()修改为:

if(ob_get_contents()) ob_end_clean();

  1. What did you see instead? As I said above