Conditions | 2 |
Paths | 1 |
Total Lines | 20 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
1 | <?php |
||
18 | public function __invoke(ConnectionInterface $conn) |
||
19 | { |
||
20 | $sink = new Sink($conn); |
||
21 | $this->master->queue->executeAsync(function (BuiltinServer $process) use ($conn, $sink) { |
||
22 | $deferred = new Deferred; |
||
23 | try { |
||
24 | $child = new Stream($process->getSocketClient(), $this->master->loop); |
||
25 | $sink->pipe($child); |
||
26 | $child->pipe($conn); |
||
27 | $child->on('close', function () use ($deferred) { |
||
28 | $deferred->resolve(); |
||
29 | }); |
||
30 | } catch (\RuntimeException $e) { |
||
31 | $conn->write("HTTP/1.0 502 Bad Gateway\r\n"); |
||
32 | $conn->end("\r\n"); |
||
33 | $deferred->resolve(); |
||
34 | } |
||
35 | return $deferred->promise(); |
||
36 | }); |
||
37 | } |
||
38 | } |
||
39 |