35539-vm/vendor/cboden/ratchet/src/Ratchet/Http/CloseResponseTrait.php
Flatlogic Bot 7794e16d3d Websocket
2025-11-07 06:54:43 +00:00

23 lines
669 B
PHP

<?php
namespace Ratchet\Http;
use Ratchet\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' => \Ratchet\VERSION
], $additional_headers));
$conn->send(Message::toString($response));
$conn->close();
}
}