Example #1
0
 /**
  * Sending http header with defined http attributes.
  *
  * @return \Avenue\Response
  */
 public function sendHttpHeaders()
 {
     $statusCode = $this->getStatusCode();
     $statusDescription = $this->getStatusDescription($statusCode);
     $httpVersion = $this->app->getHttpVersion();
     $httpProtocol = sprintf('HTTP/%s', !empty($httpVersion) ? $httpVersion : '1.1');
     $body = $this->getBody();
     if (is_int($statusCode)) {
         header(sprintf('%s %d %s', $httpProtocol, $statusCode, $statusDescription), true, $statusCode);
     }
     if (!$this->hasCache() && !empty($body)) {
         header(sprintf('Content-Length: %d', strlen($body)));
     }
     unset($statusCode, $statusDescription, $httpProtocol, $body);
     return $this;
 }