diff options
-rw-r--r-- | .travis.yml | 9 | ||||
-rw-r--r--[-rwxr-xr-x] | build.sh | 2 | ||||
-rw-r--r-- | src/PSR7Client.php | 17 |
3 files changed, 18 insertions, 10 deletions
diff --git a/.travis.yml b/.travis.yml index 3e0f94f8..6dd312df 100644 --- a/.travis.yml +++ b/.travis.yml @@ -62,4 +62,13 @@ jobs: - sudo apt-get install -y php7.2-cli - sudo cp `which php7.2` `which php` - php -v + - composer self-update + - stage: Test + env: "PHP=7.3" + before_install: + - sudo add-apt-repository -y ppa:ondrej/php + - sudo apt-get update + - sudo apt-get install -y php7.3-cli + - sudo cp `which php7.3` `which php` + - php -v - composer self-update
\ No newline at end of file @@ -2,7 +2,7 @@ cd $(dirname "${BASH_SOURCE[0]}") OD="$(pwd)" # Pushes application version into the build information. -RR_VERSION=1.2.6 +RR_VERSION=1.2.7 # Hardcode some values to the core package LDFLAGS="$LDFLAGS -X github.com/spiral/roadrunner/cmd/rr/cmd.Version=${RR_VERSION}" diff --git a/src/PSR7Client.php b/src/PSR7Client.php index 2da53c26..129cb118 100644 --- a/src/PSR7Client.php +++ b/src/PSR7Client.php @@ -32,11 +32,7 @@ class PSR7Client private $uploadsFactory; /** @var array Valid values for HTTP protocol version */ - public static $allowedProtocolVersions = [ - '1.0', - '1.1', - '2', - ]; + private static $allowedVersions = ['1.0', '1.1', '2',]; /** * @param Worker $worker @@ -91,7 +87,7 @@ class PSR7Client parse_str($ctx['rawQuery'], $query); $request = $request - ->withProtocolVersion(static::normalizeHttpProtocolVersion($ctx['protocol'])) + ->withProtocolVersion(static::fetchProtocolVersion($ctx['protocol'])) ->withCookieParams($ctx['cookies']) ->withQueryParams($query) ->withUploadedFiles($this->wrapUploads($ctx['uploads'])); @@ -147,6 +143,8 @@ class PSR7Client $server['REQUEST_TIME'] = time(); $server['REQUEST_TIME_FLOAT'] = microtime(true); $server['REMOTE_ADDR'] = $ctx['attributes']['ipAddress'] ?? $ctx['remoteAddr'] ?? '127.0.0.1'; + $server['REMOTE_ADDR'] = $ctx['attributes']['ipAddress'] ?? $ctx['remoteAddr'] ?? '127.0.0.1'; + $server['HTTP_USER_AGENT'] = $ctx['headers']['User-Agent'][0] ?? ''; return $server; } @@ -191,19 +189,20 @@ class PSR7Client /** * Normalize HTTP protocol version to valid values + * * @param string $version * @return string */ - public static function normalizeHttpProtocolVersion(string $version): string + private static function fetchProtocolVersion(string $version): string { $v = substr($version, 5); if ($v === '2.0') { - $v = '2'; + return '2'; } // Fallback for values outside of valid protocol versions - if (!in_array($v, static::$allowedProtocolVersions, true)) { + if (!in_array($v, static::$allowedVersions, true)) { return '1.1'; } |