| 1 | <?php |
||
| 12 | final class HttpClient |
||
| 13 | { |
||
| 14 | /** @var Worker */ |
||
| 15 | private $worker; |
||
| 16 | |||
| 17 | /** |
||
| 18 | * @param Worker $worker |
||
| 19 | */ |
||
| 20 | public function __construct(Worker $worker) |
||
| 24 | |||
| 25 | /** |
||
| 26 | * @return Worker |
||
| 27 | */ |
||
| 28 | public function getWorker(): Worker |
||
| 32 | |||
| 33 | /** |
||
| 34 | * @return mixed[]|null Request information as ['ctx'=>[], 'body'=>string] |
||
| 35 | * or null if termination request or invalid context. |
||
| 36 | */ |
||
| 37 | public function acceptRequest(): ?array |
||
| 53 | |||
| 54 | /** |
||
| 55 | * Send response to the application server. |
||
| 56 | * |
||
| 57 | * @param int $status Http status code |
||
| 58 | * @param string $body Body of response |
||
| 59 | * @param string[][] $headers An associative array of the message's headers. Each |
||
| 60 | * key MUST be a header name, and each value MUST be an array of strings |
||
| 61 | * for that header. |
||
| 62 | */ |
||
| 63 | public function respond(int $status, string $body, array $headers = []): void |
||
| 75 | } |
||
| 76 |