| 1 | <?php |
||
| 7 | class HttpTransport implements TransportInterface |
||
| 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) |
||
| 40 | |||
| 41 | public function request(string $request): string |
||
| 51 | |||
| 52 | /** |
||
| 53 | * @param string $payload |
||
| 54 | * @return resource |
||
| 55 | */ |
||
| 56 | private function buildContext(string $payload) |
||
| 71 | } |
||
| 72 |