forked from reactphp/reactphp
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathClient.php
More file actions
33 lines (25 loc) · 879 Bytes
/
Copy pathClient.php
File metadata and controls
33 lines (25 loc) · 879 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
<?php
namespace React\HttpClient;
use React\EventLoop\LoopInterface;
use React\HttpClient\Request;
use React\SocketClient\ConnectorInterface;
class Client
{
private $connectionManager;
private $secureConnectionManager;
public function __construct(ConnectorInterface $connector, ConnectorInterface $secureConnector)
{
$this->connector = $connector;
$this->secureConnector = $secureConnector;
}
public function request($method, $url, array $headers = array())
{
$requestData = new RequestData($method, $url, $headers);
$connectionManager = $this->getConnectorForScheme($requestData->getScheme());
return new Request($connectionManager, $requestData);
}
private function getConnectorForScheme($scheme)
{
return ('https' === $scheme) ? $this->secureConnector : $this->connector;
}
}