-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
browser.php
32 lines (24 loc) · 896 Bytes
/
browser.php
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
<?php declare(strict_types=1);
use EdgeTelemetrics\React\Dns\DohExecutor;
use React\Cache\ArrayCache;
use React\Dns\Query\CachingExecutor;
use React\Dns\Query\TimeoutExecutor;
use React\Dns\Resolver\Resolver;
include __DIR__ . '/../vendor/autoload.php';
$cache = new ArrayCache(256);
$executor = new TimeoutExecutor(
new DohExecutor('1.1.1.1'),
5.0,
);
$executor = new CachingExecutor($executor, $cache);
$resolver = new Resolver($executor);
$endpoint = 'https://raw.githubusercontent.com/lucasnetau/reactphp-dns-over-https-client/main/README.md';
$client = (new React\Http\Browser(new React\Socket\Connector([
'tcp' => ['tcp_nodelay' => true,],
'dns' => $resolver,
'timeout' => 5.0,
])))->withTimeout(10.0);
$client->get($endpoint)->then(function (Psr\Http\Message\ResponseInterface $response) {
$body = (string)$response->getBody();
echo $body;
}, 'printf');