Skip to content

Commit 4443bce

Browse files
committed
update server for mimetypes
1 parent 2f82c8c commit 4443bce

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

src/Ubiquity/servers/workerman/WorkermanServer.php

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
<?php
22
namespace Ubiquity\servers\workerman;
33

4+
use Ubiquity\utils\base\MimeType;
45
use Workerman\Protocols\Http;
56
use Workerman\Protocols\HttpCache;
67
use Workerman\Worker;
@@ -12,7 +13,7 @@
1213
* This class is part of Ubiquity
1314
*
1415
* @author jcheron <[email protected]>
15-
* @version 1.0.2
16+
* @version 1.0.3
1617
*/
1718
class WorkermanServer {
1819

@@ -126,10 +127,11 @@ protected function handle(ConnectionInterface $connection, $datas) {
126127
$_GET['c'] = $uri;
127128
} else {
128129
if ($uriInfos['file']) {
129-
Http::header('Content-Type: ' . (HttpCache::$header['Accept'] ?? 'text/html; charset=utf-8'), true);
130+
$mime = MimeType::getFileMimeType(realpath($uri));
131+
Http::header('Content-Type: ' . $mime . '; charset=utf-8', true);
130132
return $connection->send(\file_get_contents($this->basedir . '/../' . $uri));
131133
} else {
132-
Http::header('Content-Type: ' . (HttpCache::$header['Accept'] ?? 'text/html; charset=utf-8'), true, 404);
134+
Http::header('Content-Type: text/plain; charset=utf-8', true, 404);
133135
return $connection->send($uri . ' not found!');
134136
}
135137
return;

0 commit comments

Comments
 (0)