-
Notifications
You must be signed in to change notification settings - Fork 27
Expand file tree
/
Copy pathhttp2.php
More file actions
executable file
·34 lines (29 loc) · 732 Bytes
/
http2.php
File metadata and controls
executable file
·34 lines (29 loc) · 732 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#!/usr/bin/env php
<?php
declare(strict_types=1);
/**
* In this example we start an HTTP/2 server.
*
* You can run following curl command to check HTTP/2 response headers and body:
* docker compose exec -t client bash -c "curl -i --http2-prior-knowledge http://server:9503"
*/
use Swoole\Http\Request;
use Swoole\Http\Response;
use Swoole\Http\Server;
$server = new Server('0.0.0.0', 9503, SWOOLE_BASE);
$server->set(
[
'open_http2_protocol' => true,
]
);
$server->on(
'request',
function (Request $request, Response $response): void {
$response->end(
<<<'EOT'
In this example we start an HTTP/2 server.
EOT
);
}
);
$server->start();