public function send()
{
if ($this->_sent === true) {
throw new ResponseException('Response was already sent');
}
if ($this->_file) {
if (!$this->filesystem->fileExists($this->_file)) {
throw new ResponseException('Sent file is not exists: `:file`', ['file' => $this->_file]);
}
$this->setHeader('Content-Length', $this->filesystem->fileSize($this->_file));
}
if (!headers_sent()) {
$this->sendHeaders();
}
if ($this->_content !== null) {
echo $this->_content;
} else {
if ($this->_file) {
readfile($this->alias->resolve($this->_file));
}
}
$this->_sent = true;
return $this;
}