1 | <?php |
||
29 | class RequestFactory |
||
30 | { |
||
31 | /** |
||
32 | * |
||
33 | * @param RequestInterface $request |
||
34 | * @param array $options |
||
35 | * @param HttpClient $httpClient |
||
36 | * @param LoopInterface $loop |
||
37 | * @return \React\Promise\Promise |
||
38 | */ |
||
39 | public function create(RequestInterface $request, array $options, HttpClient $httpClient, LoopInterface $loop) |
||
48 | |||
49 | protected function createSender(array $options, HttpClient $httpClient, LoopInterface $loop) |
||
50 | { |
||
51 | $connector = $this->extractConnector($httpClient); |
||
52 | |||
53 | if (isset($options['proxy'])) { |
||
54 | $resolver = $this->extractResolver($connector); |
||
55 | $connector = (new SocksClient($options['proxy'], $loop, $connector, $resolver))->createConnector(); |
||
56 | } |
||
57 | |||
58 | return Sender::createFromLoopConnectors($loop, $connector); |
||
59 | } |
||
60 | |||
61 | protected function convertOptions(array $options) |
||
65 | |||
66 | protected function extractConnector(HttpClient $httpClient) |
||
73 | |||
74 | protected function extractResolver(ConnectorInterface $connector) |
||
85 | } |
||
86 |