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

Commit 9506628

Browse files
authored
Merge pull request #34 from swooletw/develop
Develop
2 parents e5fb869 + ed40ced commit 9506628

File tree

2 files changed

+12
-5
lines changed

2 files changed

+12
-5
lines changed

src/Server/Manager.php

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -292,7 +292,9 @@ public function onRequest($swooleRequest, $swooleResponse)
292292
protected function handleStaticRequest($illuminateRequest, $swooleResponse)
293293
{
294294
$uri = $illuminateRequest->getRequestUri();
295-
if (strpos($uri, '.php') || strpos($uri, '.htaccess') || strpos($uri, '.config')) {
295+
$blackList = ['php', 'htaccess', 'config'];
296+
$extension = substr(strrchr($uri, '.'), 1);
297+
if ($extension && in_array($extension, $blackList)) {
296298
return;
297299
}
298300

@@ -304,7 +306,13 @@ protected function handleStaticRequest($illuminateRequest, $swooleResponse)
304306
}
305307

306308
$swooleResponse->status(200);
307-
$swooleResponse->header('Content-Type', mime_content_type($filename));
309+
$mime = mime_content_type($filename);
310+
if ($extension === 'js') {
311+
$mime = 'text/javascript';
312+
} elseif ($extension === 'css') {
313+
$mime = 'text/css';
314+
}
315+
$swooleResponse->header('Content-Type', $mime);
308316
$swooleResponse->sendfile($filename);
309317

310318
return true;

src/Server/Response.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -86,9 +86,8 @@ protected function sendHeaders()
8686

8787
// cookies
8888
foreach ($illuminateResponse->headers->getCookies() as $cookie) {
89-
$method = $cookie->isRaw() ? 'rawcookie' : 'cookie';
90-
91-
$this->swooleResponse->$method(
89+
// may need to consider rawcookie
90+
$this->swooleResponse->cookie(
9291
$cookie->getName(), $cookie->getValue(),
9392
$cookie->getExpiresTime(), $cookie->getPath(),
9493
$cookie->getDomain(), $cookie->isSecure(),

0 commit comments

Comments
 (0)