1: <?php
2: namespace Ratchet\Http;
3: use Ratchet\ConnectionInterface;
4: use GuzzleHttp\Psr7 as gPsr;
5: use GuzzleHttp\Psr7\Response;
6:
7: trait CloseResponseTrait {
8: /**
9: * Close a connection with an HTTP response
10: * @param \Ratchet\ConnectionInterface $conn
11: * @param int $code HTTP status code
12: * @return null
13: */
14: private function close(ConnectionInterface $conn, $code = 400, array $additional_headers = []) {
15: $response = new Response($code, array_merge([
16: 'X-Powered-By' => \Ratchet\VERSION
17: ], $additional_headers));
18:
19: $conn->send(gPsr\str($response));
20: $conn->close();
21: }
22: }