Change how disabled/supported/enabled is handled for deflate
This commit is contained in:
parent
2159ed40f9
commit
1cb14114c3
@ -32,11 +32,13 @@ class ClientNegotiator {
|
|||||||
|
|
||||||
// https://bugs.php.net/bug.php?id=73373
|
// https://bugs.php.net/bug.php?id=73373
|
||||||
// https://bugs.php.net/bug.php?id=74240 - need >=7.1.4 or >=7.0.18
|
// https://bugs.php.net/bug.php?id=74240 - need >=7.1.4 or >=7.0.18
|
||||||
$supported = PermessageDeflateOptions::permessageDeflateSupported();
|
if ($perMessageDeflateOptions->isEnabled() &&
|
||||||
if (!$supported) {
|
!PermessageDeflateOptions::permessageDeflateSupported()) {
|
||||||
if ($perMessageDeflateOptions->isEnabled()) {
|
trigger_error('permessage-deflate is being disabled because it is not support by your PHP version.', E_USER_NOTICE);
|
||||||
trigger_error('permessage-deflate is being disabled because it is not support by your PHP version.', E_USER_NOTICE);
|
$perMessageDeflateOptions = PermessageDeflateOptions::createDisabled();
|
||||||
}
|
}
|
||||||
|
if ($perMessageDeflateOptions->isEnabled() && !function_exists('deflate_add')) {
|
||||||
|
trigger_error('permessage-deflate is being disabled because you do not have the zlib extension.', E_USER_NOTICE);
|
||||||
$perMessageDeflateOptions = PermessageDeflateOptions::createDisabled();
|
$perMessageDeflateOptions = PermessageDeflateOptions::createDisabled();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -21,7 +21,7 @@ final class PermessageDeflateOptions
|
|||||||
|
|
||||||
private function __construct() { }
|
private function __construct() { }
|
||||||
|
|
||||||
public static function createDefault() {
|
public static function createEnabled() {
|
||||||
$new = new static();
|
$new = new static();
|
||||||
$new->deflateEnabled = true;
|
$new->deflateEnabled = true;
|
||||||
$new->client_max_window_bits = self::MAX_WINDOW_BITS;
|
$new->client_max_window_bits = self::MAX_WINDOW_BITS;
|
||||||
|
@ -26,12 +26,10 @@ class ServerNegotiator implements NegotiatorInterface {
|
|||||||
// https://bugs.php.net/bug.php?id=74240 - need >=7.1.4 or >=7.0.18
|
// https://bugs.php.net/bug.php?id=74240 - need >=7.1.4 or >=7.0.18
|
||||||
$supported = PermessageDeflateOptions::permessageDeflateSupported();
|
$supported = PermessageDeflateOptions::permessageDeflateSupported();
|
||||||
if ($enablePerMessageDeflate && !$supported) {
|
if ($enablePerMessageDeflate && !$supported) {
|
||||||
trigger_error('permessage-deflate is being disabled because it is not support by your PHP version.', E_USER_NOTICE);
|
throw new \Exception('permessage-deflate is not supported by your PHP version (need >=7.1.4 or >=7.0.18).');
|
||||||
$enablePerMessageDeflate = false;
|
|
||||||
}
|
}
|
||||||
if ($enablePerMessageDeflate && !function_exists('deflate_add')) {
|
if ($enablePerMessageDeflate && !function_exists('deflate_add')) {
|
||||||
trigger_error('permessage-deflate is being disabled because you do not have the zlib extension.', E_USER_NOTICE);
|
throw new \Exception('permessage-deflate is not supported because you do not have the zlib extension.');
|
||||||
$enablePerMessageDeflate = false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->enablePerMessageDeflate = $enablePerMessageDeflate;
|
$this->enablePerMessageDeflate = $enablePerMessageDeflate;
|
||||||
|
@ -107,7 +107,7 @@ function getTestCases() {
|
|||||||
return $deferred->promise();
|
return $deferred->promise();
|
||||||
}
|
}
|
||||||
|
|
||||||
$cn = new \Ratchet\RFC6455\Handshake\ClientNegotiator(PermessageDeflateOptions::createDefault());
|
$cn = new \Ratchet\RFC6455\Handshake\ClientNegotiator(PermessageDeflateOptions::createEnabled());
|
||||||
|
|
||||||
function runTest($case)
|
function runTest($case)
|
||||||
{
|
{
|
||||||
@ -120,7 +120,7 @@ function runTest($case)
|
|||||||
$deferred = new Deferred();
|
$deferred = new Deferred();
|
||||||
|
|
||||||
$connector->connect($testServer . ':9001')->then(function (ConnectionInterface $connection) use ($deferred, $casePath, $case) {
|
$connector->connect($testServer . ':9001')->then(function (ConnectionInterface $connection) use ($deferred, $casePath, $case) {
|
||||||
$cn = new ClientNegotiator(PermessageDeflateOptions::createDefault());
|
$cn = new ClientNegotiator(PermessageDeflateOptions::createEnabled());
|
||||||
$cnRequest = $cn->generateRequest(new Uri('ws://127.0.0.1:9001' . $casePath));
|
$cnRequest = $cn->generateRequest(new Uri('ws://127.0.0.1:9001' . $casePath));
|
||||||
|
|
||||||
$rawResponse = "";
|
$rawResponse = "";
|
||||||
|
Loading…
Reference in New Issue
Block a user