Skip to content

Commit

Permalink
Removed unnecessary code. Removed dependency Guzzle/PSR-7, instead ad…
Browse files Browse the repository at this point in the history
…ded Thruster HTTP Message
  • Loading branch information
Aurimas Niekis committed May 31, 2016
1 parent 5765e4d commit e2d5317
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 13 deletions.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
"thruster/event-emitter": "~1.0",
"thruster/server-application": "~0.1",
"thruster/http-modifiers": "~1.0",
"guzzlehttp/psr7": "~1.2"
"thruster/http-message": "^1.1"
},
"require-dev": {
"phpunit/phpunit": "~5.0"
Expand Down
32 changes: 20 additions & 12 deletions src/HttpServer.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,15 @@

namespace Thruster\Component\HttpServer;

use GuzzleHttp\Psr7\Response;
use Psr\Http\Message\ResponseInterface;
use Psr\Http\Message\ServerRequestInterface;
use Thruster\Component\Promise\PromiseInterface;
use Thruster\Component\Socket\Server;
use Thruster\Component\Socket\Connection;
use Thruster\Component\Socket\ServerInterface;
use Thruster\Component\Socket\ConnectionInterface;
use Thruster\Component\HttpModifier\RequestModifierInterface;
use Thruster\Component\HttpMessage\Response;
use Thruster\Component\HttpModifier\ResponseModifierInterface;
use Thruster\Component\HttpModifier\RequestModifierCollection;
use Thruster\Component\HttpModifier\ResponseModifierCollection;
use Thruster\Component\HttpModifier\ServerRequestModifierInterface;
use Thruster\Component\HttpModifier\ServerRequestModifierCollection;
use Thruster\Component\HttpModifiers\AddServerTimeModifier;
use Thruster\Component\HttpModifiers\AddServerPoweredByModifier;
Expand All @@ -34,6 +31,11 @@ class HttpServer
*/
private $application;

/**
* @var bool
*/
private $applicationPreloaded;

/**
* @var Server[]
*/
Expand Down Expand Up @@ -71,12 +73,13 @@ class HttpServer

private function __construct(ServerApplicationInterface $application)
{
$this->application = $application;
$this->servers = [];
$this->debug = false;
$this->servedRequests = 0;
$this->failedRequests = 0;
$this->upTime = time();
$this->application = $application;
$this->applicationPreloaded = false;
$this->servers = [];
$this->debug = false;
$this->servedRequests = 0;
$this->failedRequests = 0;
$this->upTime = time();

$this->requestModifiers = new ServerRequestModifierCollection();
$this->responseModifiers = new ResponseModifierCollection(
Expand All @@ -98,13 +101,18 @@ public function attachTo(ServerInterface $server) : self
return $this;
}

if (false === $this->applicationPreloaded) {
$this->application->preloadApplication();
$this->applicationPreloaded = true;
}

$this->servers[] = $server;
$this->listenTo($server);

return $this;
}

public function withRequestModifier(RequestModifierInterface $modifier) : self
public function withRequestModifier(ServerRequestModifierInterface $modifier) : self
{
$this->requestModifiers->add($modifier);

Expand Down

0 comments on commit e2d5317

Please sign in to comment.