Exemplo n.º 1
0
 /**
  * Send a response to the browser
  * 
  * @param integer $status Status code
  * @param string  $html   HTML code to send
  * @param string  $contentType content code to send
  * @return void
  */
 public function respond($status, $html, $contentType)
 {
     $statusMsg = "Internal Server Error";
     if (isset(WebBotServer::$errorCodes[$status])) {
         $statusMsg = WebBotServer::$errorCodes[$status];
     }
     // Transfer-Encoding: chunked
     // http://en.wikipedia.org/wiki/Chunked_transfer_encoding
     // dechex(len)\r\n CHUNK \r\n0
     $this->handler->put("HTTP/1.1 {$status} {$statusMsg}\r\n");
     $this->handler->put("Content-type: {$contentType}\r\n");
     $this->handler->put("Content-Length: " . strlen($html) . "\r\n");
     $this->handler->put("Connection: Close\r\n");
     $this->handler->put("Date: " . date('r') . "\r\n");
     $this->handler->put("Server: neotor/1.1 WebBot/0.1\r\n");
     $this->handler->put("\r\n");
     $this->handler->put($html);
     $this->handler->close();
 }
Exemplo n.º 2
0
 public function put($data, $silent = 0, $norn = 0)
 {
     $this->handler->put($data . ($norn == 0 ? "\r\n" : ''));
 }