mirror of
https://gitee.com/hyperf/hyperf.git
synced 2024-11-30 02:37:58 +08:00
fix #433: set open_http_protocol and open_http2_protocol to false when server type is tcp
This commit is contained in:
parent
9058caa852
commit
d641683bce
@ -52,6 +52,7 @@ class Port
|
||||
public static function build(array $config)
|
||||
{
|
||||
$port = new static();
|
||||
self::filter($config);
|
||||
isset($config['name']) && $port->setName($config['name']);
|
||||
isset($config['type']) && $port->setType($config['type']);
|
||||
isset($config['host']) && $port->setHost($config['host']);
|
||||
@ -138,4 +139,14 @@ class Port
|
||||
$this->settings = $settings;
|
||||
return $this;
|
||||
}
|
||||
|
||||
private static function filter(array &$config)
|
||||
{
|
||||
if ($config['type'] == ServerInterface::SERVER_TCP) {
|
||||
$config['settings'] = array_replace($config['settings'] ?? [], [
|
||||
'open_http2_protocol' => false,
|
||||
'open_http_protocol' => false,
|
||||
]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -112,6 +112,9 @@ class Server implements ServerInterface
|
||||
} else {
|
||||
/** @var \Swoole\Server\Port $slaveServer */
|
||||
$slaveServer = $this->server->addlistener($host, $port, $sockType);
|
||||
if (! $slaveServer) {
|
||||
throw new \RuntimeException("Failed to listen server port [{$host}:{$port}]");
|
||||
}
|
||||
$server->getSettings() && $slaveServer->set($server->getSettings());
|
||||
$this->registerSwooleEvents($slaveServer, $callbacks, $name);
|
||||
ServerManager::add($name, [$type, $slaveServer]);
|
||||
@ -177,7 +180,7 @@ class Server implements ServerInterface
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Port|SwooleServer $server
|
||||
* @param \Swoole\Server\Port|SwooleServer $server
|
||||
*/
|
||||
protected function registerSwooleEvents($server, array $events, string $serverName): void
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user