public static function sendResponse(Response $response) { $statusCode = $response->getStatusCode(); $reasonPhrase = $response->getReasonPhrase(); $protocolVersion = $response->getProtocolVersion(); echo "HTTP/{$protocolVersion} {$statusCode} {$reasonPhrase}" . PHP_EOL; foreach ($response->getHeaders() as $headerName => $headerValues) { echo $headerName . ": " . implode(", ", $headerValues) . PHP_EOL; } echo (string) $response->getBody(); }
public static function sendResponse(Response $response) { $statusCode = $response->getStatusCode(); $reasonPhrase = $response->getReasonPhrase(); $protocolVersion = $response->getProtocolVersion(); $GLOBALS["http_response_code"] = $statusCode; header("HTTP/{$protocolVersion} {$statusCode} {$reasonPhrase}"); foreach ($response->getHeaders() as $headerName => $headerValues) { header($headerName . ": " . implode(", ", $headerValues)); } echo (string) $response->getBody(); }