1 | <?php |
||
7 | class HttpTransport extends AbstractTransport |
||
8 | { |
||
9 | /** |
||
10 | * @var string |
||
11 | */ |
||
12 | private $url; |
||
13 | |||
14 | /** |
||
15 | * @var int |
||
16 | */ |
||
17 | private $timeout; |
||
18 | |||
19 | /** |
||
20 | * @var array |
||
21 | */ |
||
22 | private $headers = [ |
||
23 | 'User-Agent: PhpJsonRpc client <https://github.com/vaderangry/PhpJsonRpc>', |
||
24 | 'Content-Type: application/json', |
||
25 | 'Accept: application/json', |
||
26 | 'Connection: close', |
||
27 | ]; |
||
28 | |||
29 | /** |
||
30 | * HttpEngine constructor. |
||
31 | * |
||
32 | * @param string $url URL of RPC server |
||
33 | * @param int $timeout HTTP timeout |
||
34 | */ |
||
35 | public function __construct(string $url, int $timeout = null) |
||
42 | |||
43 | /** |
||
44 | * Send request |
||
45 | * |
||
46 | * @param string $request |
||
47 | * |
||
48 | * @return string |
||
49 | */ |
||
50 | public function send(string $request): string |
||
60 | |||
61 | /** |
||
62 | * Add headers to any request |
||
63 | * |
||
64 | * @param array $headers |
||
65 | */ |
||
66 | public function addHeaders(array $headers) |
||
70 | |||
71 | /** |
||
72 | * @param string $payload |
||
73 | * @return resource |
||
74 | */ |
||
75 | private function buildContext(string $payload) |
||
90 | } |
||
91 |