public function writeHead($status = 200, array $headers = array()) { if ($this->headWritten) { throw new \Exception('Response head has already been written.'); } if (isset($headers['Content-Length'])) { $this->chunkedEncoding = false; } $response = new GuzzleResponse($status); $response->setHeader('X-Powered-By', 'React/alpha'); $response->addHeaders($headers); if ($this->chunkedEncoding) { $response->setHeader('Transfer-Encoding', 'chunked'); } $data = (string) $response; $this->conn->write($data); $this->headWritten = true; }