Skip to content

Commit b2ffc7e

Browse files
committed
Fix GH-5858
1 parent 1f165fd commit b2ffc7e

File tree

2 files changed

+42
-0
lines changed

2 files changed

+42
-0
lines changed

ext-src/swoole_socket_coro.cc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -884,6 +884,9 @@ SW_API bool php_swoole_socket_set_protocol(Socket *sock, zval *zset) {
884884
sock->enable_ssl_encrypt();
885885
}
886886
}
887+
if (php_swoole_array_get_value(vht, "open_http2_protocol", ztmp)) {
888+
sock->http2 = zval_is_true(ztmp);
889+
}
887890
if (sock->ssl_is_enable()) {
888891
if (!php_swoole_socket_set_ssl(sock, zset)) {
889892
ret = false;
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
--TEST--
2+
swoole_http_server_coro: http2 + SSL
3+
--SKIPIF--
4+
<?php require __DIR__ . '/../include/skipif.inc'; ?>
5+
--FILE--
6+
<?php
7+
require __DIR__ . '/../include/bootstrap.php';
8+
9+
$port = get_one_free_port();
10+
11+
\Swoole\Runtime::setHookFlags(SWOOLE_HOOK_ALL);
12+
13+
go(function () use ($port) {
14+
$server = new Co\Http\Server("127.0.0.1", $port, true);
15+
$server->set([
16+
'open_http2_protocol' => true,
17+
'open_tcp_nodelay' => true,
18+
'ssl_cert_file' => SSL_FILE_DIR . '/server.crt',
19+
'ssl_key_file' => SSL_FILE_DIR . '/server.key',
20+
]);
21+
$server->handle('/', function ($request, $response) {
22+
$response->end("<h1>Index</h1>");
23+
});
24+
$server->handle('/stop', function ($request, $response) use ($server) {
25+
$response->end("<h1>Stop</h1>");
26+
$server->shutdown();
27+
});
28+
$server->start();
29+
});
30+
31+
go(function () use ($port) {
32+
echo shell_exec("curl --no-progress-meter --http2 -k https://127.0.0.1:$port/") . PHP_EOL;
33+
echo shell_exec("curl --no-progress-meter --http2 -k https://127.0.0.1:$port/stop") . PHP_EOL;
34+
});
35+
Swoole\Event::wait();
36+
?>
37+
--EXPECT--
38+
<h1>Index</h1>
39+
<h1>Stop</h1>

0 commit comments

Comments
 (0)