Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

有时候的返回是正常的,有时候又是204 #423

Open
dengao123 opened this issue Dec 1, 2022 · 0 comments
Open

有时候的返回是正常的,有时候又是204 #423

dengao123 opened this issue Dec 1, 2022 · 0 comments
Assignees
Labels
analyzing Analyzing this issue

Comments

@dengao123
Copy link

dengao123 commented Dec 1, 2022

  1. Your software version (Screenshot of your startup)

    Software Version
    PHP 7.4.21
    Swoole 4.8.12
    Laravel 5.7.26
  2. Detail description about this issue(error/log)
    前后端分离的项目,单独的网页请求是正常的,前端跨域请求就会偶尔报204错误。我加了日志后发现,
    发现:在\vendor\hhxsv5\laravel-s\src\Illuminate\Laravel.php的handleDynamic()中

public function handleDynamic(IlluminateRequest $request) {

    ob_start();
    if ($this->conf['is_lumen']) {
           ....
    } else {
        $response = $this->kernel->handle($request);
        $content = $response->getContent();
        app('log')->info('kernel get content is '. json_encode($content));    //这里打印的content偶尔为空值,所以返回给前端显示204
        $this->kernel->terminate($request, $response);
    }
    // prefer content in response, secondly ob
    if (!($response instanceof StreamedResponse) && (string)$content === '' && ob_get_length() > 0) {
        $response->setContent(ob_get_contents());
    }
    ob_end_clean();
    return $response;
} 
@dengao123 dengao123 added the analyzing Analyzing this issue label Dec 1, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
analyzing Analyzing this issue
Projects
None yet
Development

No branches or pull requests

2 participants