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

getHandler 的一点疑问 #16

Open
limingxinleo opened this issue Jul 24, 2020 · 1 comment
Open

getHandler 的一点疑问 #16

limingxinleo opened this issue Jul 24, 2020 · 1 comment

Comments

@limingxinleo
Copy link

Http 那里,我感觉有点问题

以下这个方法,如果存在 $default['handler'] 的话,感觉不应该当成一个 middleware push 进来,而是直接使用 setHandler 吧

    protected function getHandler()
    {
        $stack = HandlerStack::create();

        foreach ($this->middlewares as $middleware) {
            $stack->push($middleware);
        }

        if (isset(static::$defaults['handler']) && is_callable(static::$defaults['handler'])) {
            $stack->push(static::$defaults['handler'], self::USER_DEFINED_HANDLER);
        }

        if (isset($this->app['guzzle_handler'])) {
            $guzzleHandler = $this->app['guzzle_handler'];
            $stack->setHandler(is_string($guzzleHandler) ? new $guzzleHandler() : $this->app['guzzle_handler']);
        }

        return $stack;
    }
@tb07
Copy link

tb07 commented Sep 8, 2023

我在使用中也遇到了这问题
我现在打算和你一样去掉
if ($this->stack) {
return $this->stack;
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants