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=74240 - need >=7.1.4 or >=7.0.18
|
||||
$supported = PermessageDeflateOptions::permessageDeflateSupported();
|
||||
if (!$supported) {
|
||||
if ($perMessageDeflateOptions->isEnabled()) {
|
||||
if ($perMessageDeflateOptions->isEnabled() &&
|
||||
!PermessageDeflateOptions::permessageDeflateSupported()) {
|
||||
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();
|
||||
}
|
||||
|
||||
|
@ -21,7 +21,7 @@ final class PermessageDeflateOptions
|
||||
|
||||
private function __construct() { }
|
||||
|
||||
public static function createDefault() {
|
||||
public static function createEnabled() {
|
||||
$new = new static();
|
||||
$new->deflateEnabled = true;
|
||||
$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
|
||||
$supported = PermessageDeflateOptions::permessageDeflateSupported();
|
||||
if ($enablePerMessageDeflate && !$supported) {
|
||||
trigger_error('permessage-deflate is being disabled because it is not support by your PHP version.', E_USER_NOTICE);
|
||||
$enablePerMessageDeflate = false;
|
||||
throw new \Exception('permessage-deflate is not supported by your PHP version (need >=7.1.4 or >=7.0.18).');
|
||||
}
|
||||
if ($enablePerMessageDeflate && !function_exists('deflate_add')) {
|
||||
trigger_error('permessage-deflate is being disabled because you do not have the zlib extension.', E_USER_NOTICE);
|
||||
$enablePerMessageDeflate = false;
|
||||
throw new \Exception('permessage-deflate is not supported because you do not have the zlib extension.');
|
||||
}
|
||||
|
||||
$this->enablePerMessageDeflate = $enablePerMessageDeflate;
|
||||
|
@ -107,7 +107,7 @@ function getTestCases() {
|
||||
return $deferred->promise();
|
||||
}
|
||||
|
||||
$cn = new \Ratchet\RFC6455\Handshake\ClientNegotiator(PermessageDeflateOptions::createDefault());
|
||||
$cn = new \Ratchet\RFC6455\Handshake\ClientNegotiator(PermessageDeflateOptions::createEnabled());
|
||||
|
||||
function runTest($case)
|
||||
{
|
||||
@ -120,7 +120,7 @@ function runTest($case)
|
||||
$deferred = new Deferred();
|
||||
|
||||
$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));
|
||||
|
||||
$rawResponse = "";
|
||||
|
Loading…
Reference in New Issue
Block a user