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

There is a problem with the getHeader method in Psr/Message.php #6

Closed
federicomaffucci opened this issue Feb 12, 2025 · 1 comment
Closed

Comments

@federicomaffucci
Copy link

Updating the package to version 22.2.0 broke everything for me due to an invalid typing in this snippet.

ERROR php_swoole_server_rshutdown() (ERRNO 503): Fatal error: Uncaught TypeError: OpenSwoole\Core\Psr\Message::getHeader(): Return value must be of type array, string returned in /var/www/vendor/openswoole/core/src/Psr/Message.php:111

    public function getHeader(string $name): array
    {
        return $this->hasHeader($name) ? $this->headers[strtolower($name)] : [];
    }

It's not always an array, in my case it's simply the retrieval of the "Authorization" header
Bearer xxxxxxxxxx.xxxxxxxxxx.xxxxxxx

I remedied the situation like this:

    public function getHeader(string $name): array|string
    {
        return $this->hasHeader($name) ? $this->headers[strtolower($name)] : [];
    }

What do you think? Have you encountered this problem?

Copy link

@federicomaffucci this repo is read only. Please post your issues or PR at https://github.com/openswoole/openswoole

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

1 participant