Cake\Network\Response::send PHP Method

send() public method

Will echo out the content in the response body.
public send ( ) : void
return void
    public function send()
    {
        if (isset($this->_headers['Location']) && $this->_status === 200) {
            $this->statusCode(302);
        }
        $this->_setContent();
        $this->sendHeaders();
        if ($this->_file) {
            $this->_sendFile($this->_file, $this->_fileRange);
            $this->_file = $this->_fileRange = null;
        } else {
            $this->_sendContent($this->_body);
        }
        if (function_exists('fastcgi_finish_request')) {
            fastcgi_finish_request();
        }
    }

Usage Example

 /**
  * Main functionality to trigger maintenance mode.
  * Will automatically set the appropriate headers.
  *
  * Tip: Check for non CLI first
  *
  *  if (php_sapi_name() !== 'cli') {
  *    App::uses('MaintenanceLib', 'Setup.Lib');
  *    $Maintenance = new MaintenanceLib();
  *    $Maintenance->checkMaintenance();
  *  }
  *
  * @param string|null $ipAddress
  * @param bool $exit If Response should be sent and exited.
  * @return void
  * @deprecated Use Maintenance DispatcherFilter
  */
 public function checkMaintenance($ipAddress = null, $exit = true)
 {
     if ($ipAddress === null) {
         $ipAddress = env('REMOTE_ADDRESS');
     }
     if (!$this->isMaintenanceMode($ipAddress)) {
         return;
     }
     $Response = new Response();
     $Response->statusCode(503);
     $Response->header('Retry-After', DAY);
     $body = __d('setup', 'Maintenance work');
     $template = APP . 'Template' . DS . 'Error' . DS . $this->template;
     if (file_exists($template)) {
         $body = file_get_contents($template);
     }
     $Response->body($body);
     if ($exit) {
         $Response->send();
         exit;
     }
 }
All Usage Examples Of Cake\Network\Response::send