summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorWolfy-J <[email protected]>2018-12-20 14:46:28 +0300
committerWolfy-J <[email protected]>2018-12-20 14:46:28 +0300
commitea60c3e1eba96cd140e4c89b710de3a98f523f43 (patch)
tree9896f5b27553b2c304082ff6907be5271e983d3b /src
parentcc7341eb78629ea86aa05b4a99b4adc2c57b3d24 (diff)
- http version fix
- USER_AGENT bypass - added PHP7.3 to travis (travis, are you ok?)
Diffstat (limited to 'src')
-rw-r--r--src/PSR7Client.php17
1 files changed, 8 insertions, 9 deletions
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';
}