Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
},
"require-dev": {
"phpunit/phpunit": "^7.5",
"swoft/swoole-ide-helper": "dev-master"
"swoole/ide-helper": "dev-master"
},
"replace": {
"swoft/annotation": "self.version",
Expand Down
36 changes: 21 additions & 15 deletions src/http-server/test/testing/MockResponse.php
Original file line number Diff line number Diff line change
Expand Up @@ -80,14 +80,15 @@ public function header($key, $value, $ucwords = null)
}

/**
* @param string $name
* @param string $value
* @param int|string $expires
* @param string|null $path
* @param string $domain
* @param bool $secure
* @param bool $httpOnly
* @param null $samesite
* @param string $name
* @param string|null $value
* @param int|string|null $expires
* @param string|null $path
* @param string|null $domain
* @param bool|null $secure
* @param bool|null $httpOnly
* @param string|null $samesite
* @param string|null $priority
*/
public function cookie(
$name,
Expand All @@ -97,7 +98,8 @@ public function cookie(
$domain = null,
$secure = null,
$httpOnly = null,
$samesite = null
$samesite = null,
$priority = null
) {
$result = \urlencode($name) . '=' . \urlencode($value);

Expand All @@ -117,22 +119,26 @@ public function cookie(
}

if ($timestamp !== 0) {
$result .= '; expires=' . \gmdate('D, d-M-Y H:i:s e', $timestamp);
$result .= '; Expires=' . \gmdate('D, d-M-Y H:i:s e', $timestamp);
}
}

if ($secure) {
$result .= '; secure';
$result .= '; Secure';
}

// if ($hostOnly) {
// $result .= '; HostOnly';
// }

if ($httpOnly) {
$result .= '; HttpOnly';
}

if ($samesite) {
$result .= '; SameSite=' . $samesite;
}

if ($priority) {
$result .= '; Priority=' . $priority;
}

$this->cookie[$name] = $result;
}

Expand Down
15 changes: 13 additions & 2 deletions src/redis/src/Connector/PhpRedisConnector.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
use Swoft\Redis\Exception\RedisException;
use Swoft\Stdlib\Helper\Arr;
use Swoft\Stdlib\Helper\JsonHelper;
use function version_compare;

/**
* Class PhpRedisConnector
Expand All @@ -30,6 +31,11 @@ class PhpRedisConnector implements ConnectorInterface
*/
public function connect(array $config, array $option): Redis
{
if (isset($option['auth'])) {
$config['auth'] = $option['auth'];
unset($option['auth']);
}

$client = new Redis();
$this->establishConnection($client, $config);

Expand Down Expand Up @@ -159,12 +165,17 @@ protected function establishConnection(Redis $client, array $config): void
$config['host'],
$config['port'],
$config['timeout'],
'',
null,
$config['retry_interval'],
];

if (version_compare(phpversion('redis'), '3.1.3', '>=')) {
$redisVersion = \phpversion('redis');
if (\version_compare($redisVersion, '3.1.3', '>=')) {
$parameters[] = $config['read_timeout'];

if (!empty($config['auth']) && \version_compare($redisVersion, '3.5', '>=')) {
$parameters[] = ['auth' => $config['auth']];
}
}

$result = $client->connect(...$parameters);
Expand Down