openswoole / ext-openswoole

Programmatic server for PHP with async IO, coroutines and fibers
https://openswoole.com
Apache License 2.0
808 stars 51 forks source link

PSR-7 $request->getServerParams should be upper case (?) #355

Open jsanahuja opened 9 months ago

jsanahuja commented 9 months ago
  1. What did you do? If possible, provide a simple script for reproducing the error. I was trying to migrate from imefisto/psr-swoole-native to OpenSwoole PSR-7 and started using

    $server->setHandler($app)
  2. What did you expect to see? I expected everything to work but seems like all the middlewares I use (third party) expect getServerParams keys to be uppercase. Openswoole sets them lowercase. I haven't found any specification to be uppercase but the interface stats:

    /**
     * Retrieve server parameters.
     *
     * Retrieves data related to the incoming request environment,
     * typically derived from PHP's $_SERVER superglobal. The data IS NOT
     * REQUIRED to originate from $_SERVER.
     *
     * @return array
     */
    public function getServerParams();

    And since $_SERVER keys are uppercase, I would say this is an error in Openswoole.

  3. What did you see instead?

    (
    [request_method] => POST
    [request_uri] => /my/super/special/api
    [path_info] => /my/super/special/api
    [request_time] => 1707756857
    [request_time_float] => 1707756857.8345
    [server_protocol] => HTTP/1.0
    [server_port] => 10001
    [remote_port] => 50396
    [remote_addr] => 172.22.0.3
    [master_time] => 1707756857
    )
  4. What version of OpenSwoole are you using (show your php --ri openswoole)?

    
    # php --ri openswoole

openswoole

Open Swoole => enabled Author => Open Swoole Group hello@openswoole.com Version => 22.1.2 Built => Dec 10 2023 21:17:21 coroutine => enabled with boost asm context epoll => enabled eventfd => enabled signalfd => enabled spinlock => enabled rwlock => enabled sockets => enabled openssl => OpenSSL 1.1.1w 11 Sep 2023 dtls => enabled http2 => enabled hook-curl => enabled pcre => enabled zlib => 1.2.12 brotli => E16777225/D16777225 mutex_timedlock => enabled pthread_barrier => enabled futex => enabled mysqlnd => enabled postgresql => enabled

Directive => Local Value => Master Value openswoole.enable_coroutine => On => On openswoole.enable_preemptive_scheduler => Off => Off openswoole.display_errors => On => On openswoole.unixsock_buffer_size => 8388608 => 8388608

5. What is your machine environment used (show your `uname -a` & `php -v` & `gcc -v`) ?
Docker image `openswoole/swoole:22.1-php8.2-alpine` with some adds
```bash
# uname -a && php -v && gcc -v
Linux 8156544c9d25 5.15.133.1-microsoft-standard-WSL2 #1 SMP Thu Oct 5 21:02:42 UTC 2023 x86_64 Linux
PHP 8.2.0 (cli) (built: Dec  8 2022 20:14:26) (NTS)
Copyright (c) The PHP Group
Zend Engine v4.2.0, Copyright (c) Zend Technologies
sh: gcc: not found