Skip to content
This repository was archived by the owner on Mar 24, 2025. It is now read-only.

Commit 747ac63

Browse files
authored
Merge pull request #2 from swooletw/develop
Develop
2 parents f724d83 + 30972b0 commit 747ac63

File tree

5 files changed

+12
-265
lines changed

5 files changed

+12
-265
lines changed

docs/chinese.md

Lines changed: 0 additions & 129 deletions
This file was deleted.

docs/english.md

Lines changed: 0 additions & 130 deletions
This file was deleted.

src/Commands/HttpServerCommand.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ protected function start()
8585
$port = $this->configs['server']['port'];
8686

8787
$this->info('Starting swoole http server...');
88-
$this->info("Swoole http server listend on http://{$host}:{$port}.");
88+
$this->info("Swoole http server started: <http://{$host}:{$port}>");
8989
if ($this->isDaemon()) {
9090
$this->info('> (You can run this command to ensure the ' .
9191
'swoole_http_server process is running: ps aux|grep "swoole")');

src/Server/Application.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
namespace SwooleTW\Http\Server;
44

5-
use Illuminate\Contracts\Foundation\Application as ApplicationContract;
5+
use Illuminate\Container\Container;
66
use Illuminate\Contracts\Http\Kernel;
77
use Illuminate\Http\Request;
88

@@ -86,7 +86,7 @@ protected function loadApplication()
8686
*/
8787
public function getApplication()
8888
{
89-
if (! $this->application instanceof ApplicationContract) {
89+
if (!$this->application instanceof Container) {
9090
$this->application = $this->loadApplication();
9191
}
9292

@@ -98,7 +98,7 @@ public function getApplication()
9898
*/
9999
public function getKernel()
100100
{
101-
if (! $this->kernel instanceof Kernel) {
101+
if (!$this->kernel instanceof Kernel) {
102102
$this->kernel = $this->getApplication()->make(Kernel::class);
103103
}
104104

@@ -175,7 +175,7 @@ protected function setFramework($framework)
175175
{
176176
$framework = strtolower($framework);
177177

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

src/Server/Manager.php

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,9 +167,15 @@ public function onRequest($swooleRequest, $swooleResponse)
167167
$illuminateRequest = Request::make($swooleRequest)->toIlluminate();
168168
$illuminateResponse = $this->getApplication()->run($illuminateRequest);
169169

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

172177
// Unset request and response.
178+
$response = null;
173179
$swooleRequest = null;
174180
$swooleResponse = null;
175181
$illuminateRequest = null;

0 commit comments

Comments
 (0)