Esempio n. 1
0
 /**
  * Send the response to the device
  *
  * @param null $content
  * @param null $type
  * @param bool $return_string
  * @return mixed
  */
 public function send($content = null, $type = null, $return_string = false)
 {
     if (empty($this->content_type)) {
         $this->guessContentType();
     }
     $existing_content_type = $this->getHeader('Content-type');
     if (empty($existing_content_type)) {
         $this->addHeader('Content-type', $this->content_type . '; charset=' . strtoupper($this->getCharset()));
     }
     $this->renderHeaders();
     $response = $this->content_type->prepareContent($this->getContents());
     if ($return_string) {
         return $response;
     } else {
         echo $response;
         exit("\n");
     }
 }
Esempio n. 2
0
 /**
  * @return self
  */
 public function guessContentType()
 {
     $this->content_type = ContentType::createFromContent($this->getContentsAsString());
     return $this;
 }