mxmbsocket/src/Socket/Http/CloseResponseTrait.php
Mohamad Faeez 51828a7d3f
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
Update version
2025-04-09 18:36:55 +08:00

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();
}
}