Example #1
0
 /**
  * @param ServerRequestInterface $request
  * @param ResponseInterface $response
  */
 public function runRequest(ServerRequestInterface $request, ResponseInterface $response)
 {
     $queue = clone $this->queue;
     $response = $queue->run($request, $response);
     $reasonPhrase = $response->getReasonPhrase();
     $reasonPhrase = $reasonPhrase ? ' ' . $reasonPhrase : '';
     $this->connection->write(sprintf("HTTP/%s %d%s\r\n", $response->getProtocolVersion(), $response->getStatusCode(), $reasonPhrase));
     // additional headers
     foreach ($response->getHeaders() as $header => $values) {
         foreach ($values as $value) {
             $this->connection->write(sprintf("%s: %s\r\n", $header, $value));
         }
     }
     $this->connection->write("\r\n");
     $this->connection->end((string) $response->getBody());
     $this->emit('end');
 }
Example #2
0
 /**
  * {@inheritdoc}
  */
 public function close()
 {
     $this->conn->end();
 }