Example #1
0
 /**
  * Send the HTTP headers to the client.
  *
  * @param bool $include_content_length Optionaly disable the Content-Length header.
  */
 public function sendHeaders($include_content_length = true)
 {
     if (headers_sent()) {
         return;
     }
     if ($include_content_length) {
         $this->headers->set('Content-Length', $this->length);
     }
     if (in_array($this->httpStatus, [204, 304])) {
         $this->headers->remove('Content-Type');
     }
     header(sprintf('HTTP/%s %s %s', $this->httpVersion, $this->getHttpStatus(), $this->getHttpStatus(true)));
     foreach ($this->headers->all() as $index => $value) {
         header(sprintf('%s: %s', $index, $value));
     }
 }