Bluz\Response\Response::send PHP Method

send() public method

send
public send ( )
    public function send()
    {
        $body = $this->getBody();
        $this->sendCookies();
        switch (true) {
            case 'CLI' == $this->type:
                // CLI response
                $response = new CliResponse($body->render('CLI'), $this->getStatusCode());
                break;
            case is_null($body):
            case 204 == $this->getStatusCode():
                $response = new EmptyResponse($this->getStatusCode(), $this->getHeaders());
                break;
            case 301 == $this->getStatusCode():
            case 302 == $this->getStatusCode():
                $response = new RedirectResponse($this->getHeader('Location'), $this->getStatusCode(), $this->getHeaders());
                break;
            case 'JSON' == $this->type:
                // JSON response
                // setup messages
                if (Messages::count()) {
                    $this->setHeader('Bluz-Notify', json_encode(Messages::popAll()));
                }
                // encode body data to JSON
                $response = new JsonResponse($body, $this->getStatusCode(), $this->getHeaders());
                break;
            case 'HTML' == $this->type:
            default:
                // HTML response
                $response = new HtmlResponse((string) $body, $this->getStatusCode(), $this->getHeaders());
                break;
        }
        $emitter = new SapiEmitter();
        $emitter->emit($response);
    }