public static function sendResponse(ResponseInterface $response)
    {
        header('HTTP/'.$response->getHttpVersion().' '.$response->getStatus().' '.$response->getStatusText());
        foreach ($response->getHeaders() as $key => $value) {
            foreach ($value as $k => $v) {
                if (0 === $k) {
                    header($key.': '.$v);
                } else {
                    header($key.': '.$v, false);
                }
            }
        }

        $body = $response->getBody();
        if (null === $body) {
            return;
        }

        if (is_callable($body)) {
            $body();

            return;
        }

        $contentLength = $response->getHeader('Content-Length');
        if (null !== $contentLength) {
            $output = fopen('php://output', 'wb');
            if (is_resource($body) && 'stream' == get_resource_type($body)) {
                if (PHP_INT_SIZE !== 4) {
                    // use the dedicated function on 64 Bit systems
                    stream_copy_to_stream($body, $output, (int) $contentLength);
                } else {
                    // workaround for 32 Bit systems to avoid stream_copy_to_stream
                    while (!feof($body)) {
                        fwrite($output, fread($body, 8192));
                    }
                }
            } else {
                fwrite($output, $body, (int) $contentLength);
            }
        } else {
            file_put_contents('php://output', $body);
        }

        if (is_resource($body)) {
            fclose($body);
        }
    }
public static function sendResponse(ResponseInterface $response)
    {
        header('HTTP/'.$response->getHttpVersion().' '.$response->getStatus().' '.$response->getStatusText());
        foreach ($response->getHeaders() as $key => $value) {
            foreach ($value as $k => $v) {
                if (0 === $k) {
                    header($key.': '.$v);
                } else {
                    header($key.': '.$v, false);
                }
            }
        }

        $body = $response->getBody();
        if (null === $body) {
            return;
        }

        if (is_callable($body)) {
            $body();

            return;
        }

        $contentLength = $response->getHeader('Content-Length');
        if (null !== $contentLength) {
            $output = fopen('php://output', 'wb');
            if (is_resource($body) && 'stream' == get_resource_type($body)) {
                if (PHP_INT_SIZE !== 4) {
                    // use the dedicated function on 64 Bit systems
                    stream_copy_to_stream($body, $output, (int) $contentLength);
                } else {
                    // workaround for 32 Bit systems to avoid stream_copy_to_stream
                    while (!feof($body)) {
                        fwrite($output, fread($body, 8192));
                    }
                }
            } else {
                fwrite($output, $body, (int) $contentLength);
            }
        } else {
            file_put_contents('php://output', $body);
        }

        if (is_resource($body)) {
            fclose($body);
        }
    }
public static function sendResponse ( ResponseInterface $ response ) { header ( 'HTTP/' . $ response -> getHttpVersion ( ) . ' ' . $ response -> getStatus ( ) . ' ' . $ response -> getStatusText ( ) ) ; foreach ( $ response -> getHeaders ( ) as $ key => $ value ) { foreach ( $ value as $ k => $ v ) { if ( 0 === $ k ) { header ( $ key . ': ' . $ v ) ; } else { header ( $ key . ': ' . $ v , false ) ; } } } $ body = $ response -> getBody ( ) ; if ( null === $ body ) { return ; } if ( is_callable ( $ body ) ) { $ body ( ) ; return ; } $ contentLength = $ response -> getHeader ( 'Content-Length' ) ; if ( null !== $ contentLength ) { $ output = fopen ( 'php://output' , 'wb' ) ; if ( is_resource ( $ body ) && 'stream' == get_resource_type ( $ body ) ) { if ( PHP_INT_SIZE !== 4 ) { // use the dedicated function on 64 Bit systems stream_copy_to_stream ( $ body , $ output , ( int ) $ contentLength ) ; } else { // workaround for 32 Bit systems to avoid stream_copy_to_stream while ( ! feof ( $ body ) ) { fwrite ( $ output , fread ( $ body , 8192 ) ) ; } } } else { fwrite ( $ output , $ body , ( int ) $ contentLength ) ; } } else { file_put_contents ( 'php://output' , $ body ) ; } if ( is_resource ( $ body ) ) { fclose ( $ body ) ; } }
Sends the HTTP response back to a HTTP client.

This calls php's header() function and streams the body to php://output.
Sends the HTTP response back to a HTTP client .