Http components and APIs now use PSR-7 interfaces No longer using deprecated Guzzle dependency Use RFC6455 repo for WebSocket message handling Remove Hixie76 (refs #201)
		
			
				
	
	
		
			22 lines
		
	
	
		
			659 B
		
	
	
	
		
			PHP
		
	
	
	
	
	
			
		
		
	
	
			22 lines
		
	
	
		
			659 B
		
	
	
	
		
			PHP
		
	
	
	
	
	
<?php
 | 
						|
namespace Ratchet\Http;
 | 
						|
use Ratchet\ConnectionInterface;
 | 
						|
use GuzzleHttp\Psr7 as gPsr;
 | 
						|
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(gPsr\str($response));
 | 
						|
        $conn->close();
 | 
						|
    }
 | 
						|
} |