Skip to content
This repository has been archived by the owner on Sep 10, 2024. It is now read-only.

Commit

Permalink
Merge pull request #2 from swooletw/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
albertcht authored Nov 11, 2017
2 parents f724d83 + 30972b0 commit 747ac63
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 265 deletions.
129 changes: 0 additions & 129 deletions docs/chinese.md

This file was deleted.

130 changes: 0 additions & 130 deletions docs/english.md

This file was deleted.

2 changes: 1 addition & 1 deletion src/Commands/HttpServerCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ protected function start()
$port = $this->configs['server']['port'];

$this->info('Starting swoole http server...');
$this->info("Swoole http server listend on http://{$host}:{$port}.");
$this->info("Swoole http server started: <http://{$host}:{$port}>");
if ($this->isDaemon()) {
$this->info('> (You can run this command to ensure the ' .
'swoole_http_server process is running: ps aux|grep "swoole")');
Expand Down
8 changes: 4 additions & 4 deletions src/Server/Application.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

namespace SwooleTW\Http\Server;

use Illuminate\Contracts\Foundation\Application as ApplicationContract;
use Illuminate\Container\Container;
use Illuminate\Contracts\Http\Kernel;
use Illuminate\Http\Request;

Expand Down Expand Up @@ -86,7 +86,7 @@ protected function loadApplication()
*/
public function getApplication()
{
if (! $this->application instanceof ApplicationContract) {
if (!$this->application instanceof Container) {
$this->application = $this->loadApplication();
}

Expand All @@ -98,7 +98,7 @@ public function getApplication()
*/
public function getKernel()
{
if (! $this->kernel instanceof Kernel) {
if (!$this->kernel instanceof Kernel) {
$this->kernel = $this->getApplication()->make(Kernel::class);
}

Expand Down Expand Up @@ -175,7 +175,7 @@ protected function setFramework($framework)
{
$framework = strtolower($framework);

if (! in_array($framework, ['laravel', 'lumen'])) {
if (!in_array($framework, ['laravel', 'lumen'])) {
throw new \Exception(sprintf('Not support framework "%s".', $this->framework));
}

Expand Down
8 changes: 7 additions & 1 deletion src/Server/Manager.php
Original file line number Diff line number Diff line change
Expand Up @@ -167,9 +167,15 @@ public function onRequest($swooleRequest, $swooleResponse)
$illuminateRequest = Request::make($swooleRequest)->toIlluminate();
$illuminateResponse = $this->getApplication()->run($illuminateRequest);

Response::make($illuminateResponse, $swooleResponse)->send();
$response = Response::make($illuminateResponse, $swooleResponse);
// To prevent 'connection[...] is closed' error.
if (!$this->server->exist($response->getSwooleResponse()->fd)) {
return;
}
$response->send();

// Unset request and response.
$response = null;
$swooleRequest = null;
$swooleResponse = null;
$illuminateRequest = null;
Expand Down

0 comments on commit 747ac63

Please sign in to comment.