forked from php-http/react-adapter
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathReactFactory.php
39 lines (35 loc) · 929 Bytes
/
ReactFactory.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
33
34
35
36
37
38
39
<?php
namespace Http\Adapter\React;
use React\EventLoop\Loop;
use React\EventLoop\LoopInterface;
use React\Http\Browser;
use React\Socket\ConnectorInterface;
/**
* Factory wrapper for React instances.
*
* @author Stéphane Hulard <[email protected]>
*/
class ReactFactory
{
/**
* Build a react Event Loop.
*/
public static function buildEventLoop(): LoopInterface
{
return Loop::get();
}
/**
* Build a React Http Client.
*
* @param ConnectorInterface|null $connector only pass this argument if you need to customize DNS
* behaviour
*/
public static function buildHttpClient(
LoopInterface $loop,
ConnectorInterface $connector = null
): Browser {
return (new Browser($loop, $connector))
->withRejectErrorResponse(false)
->withFollowRedirects(false);
}
}