Some checks are pending
CI / PHPUnit (highest, 5.4) (push) Waiting to run
CI / PHPUnit (highest, 5.5) (push) Waiting to run
CI / PHPUnit (highest, 5.6) (push) Waiting to run
CI / PHPUnit (highest, 7.0) (push) Waiting to run
CI / PHPUnit (highest, 7.1) (push) Waiting to run
CI / PHPUnit (highest, 7.2) (push) Waiting to run
CI / PHPUnit (highest, 7.3) (push) Waiting to run
CI / PHPUnit (highest, 7.4) (push) Waiting to run
CI / PHPUnit (lowest, 5.4) (push) Waiting to run
23 lines
706 B
PHP
23 lines
706 B
PHP
<?php
|
|
namespace mfmdevsystem\socket\Http;
|
|
use mfmdevsystem\socket\ConnectionInterface;
|
|
use GuzzleHttp\Psr7\Message;
|
|
use GuzzleHttp\Psr7\Response;
|
|
|
|
trait CloseResponseTrait {
|
|
/**
|
|
* Close a connection with an HTTP response
|
|
* @param \Ratchet\ConnectionInterface $conn
|
|
* @param int $code HTTP status code
|
|
* @return null
|
|
*/
|
|
private function close(ConnectionInterface $conn, $code = 400, array $additional_headers = []) {
|
|
$response = new Response($code, array_merge([
|
|
'X-Powered-By' => \mfmdevsystem\socket\VERSION,
|
|
], $additional_headers));
|
|
|
|
$conn->send(Message::toString($response));
|
|
$conn->close();
|
|
}
|
|
}
|