|
|
@@ -67,7 +67,7 @@ class WebServer extends Man\Core\SocketWorker
|
|
|
public function onStart()
|
|
|
{
|
|
|
// 初始化HttpCache
|
|
|
- App\Common\Protocols\Http\HttpCache::init();
|
|
|
+ Man\Common\Protocols\Http\HttpCache::init();
|
|
|
// 初始化mimeMap
|
|
|
$this->initMimeTypeMap();
|
|
|
// 初始化ServerRoot
|
|
|
@@ -139,7 +139,7 @@ class WebServer extends Man\Core\SocketWorker
|
|
|
*/
|
|
|
public function dealInput($recv_str)
|
|
|
{
|
|
|
- return App\Common\Protocols\Http\http_input($recv_str);
|
|
|
+ return Man\Common\Protocols\Http\http_input($recv_str);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
@@ -149,7 +149,7 @@ class WebServer extends Man\Core\SocketWorker
|
|
|
public function dealProcess($recv_str)
|
|
|
{
|
|
|
// http请求处理开始。解析http协议,生成$_POST $_GET $_COOKIE
|
|
|
- App\Common\Protocols\Http\http_start($recv_str);
|
|
|
+ Man\Common\Protocols\Http\http_start($recv_str);
|
|
|
|
|
|
// 记录访问日志
|
|
|
$this->logAccess($recv_str);
|
|
|
@@ -158,8 +158,8 @@ class WebServer extends Man\Core\SocketWorker
|
|
|
$url_info = parse_url($_SERVER['REQUEST_URI']);
|
|
|
if(!$url_info)
|
|
|
{
|
|
|
- App\Common\Protocols\Http\header('HTTP1.1/ 400 Bad Request');
|
|
|
- return $this->sendToClient(App\Common\Protocols\Http\http_end('<h1>400 Bad Request</h1>'));
|
|
|
+ Man\Common\Protocols\Http\header('HTTP1.1/ 400 Bad Request');
|
|
|
+ return $this->sendToClient(Man\Common\Protocols\Http\http_end('<h1>400 Bad Request</h1>'));
|
|
|
}
|
|
|
|
|
|
$path = $url_info['path'];
|
|
|
@@ -177,7 +177,7 @@ class WebServer extends Man\Core\SocketWorker
|
|
|
{
|
|
|
$file_content = self::$fileCache[$path];
|
|
|
// 发送给客户端
|
|
|
- return $this->sendToClient(App\Common\Protocols\Http\http_end($file_content));
|
|
|
+ return $this->sendToClient(Man\Common\Protocols\Http\http_end($file_content));
|
|
|
}
|
|
|
|
|
|
$root_dir = isset(self::$serverRoot[$_SERVER['HTTP_HOST']]) ? self::$serverRoot[$_SERVER['HTTP_HOST']] : current(self::$serverRoot);
|
|
|
@@ -196,8 +196,8 @@ class WebServer extends Man\Core\SocketWorker
|
|
|
// 判断是否是站点目录里的文件
|
|
|
if((!($request_realpath = realpath($file)) || !($root_dir_realpath = realpath($root_dir))) || 0 !== strpos($request_realpath, $root_dir_realpath))
|
|
|
{
|
|
|
- App\Common\Protocols\Http\header('HTTP1.1/ 400 Bad Request');
|
|
|
- return $this->sendToClient(App\Common\Protocols\Http\http_end('<h1>400 Bad Request</h1>'));
|
|
|
+ Man\Common\Protocols\Http\header('HTTP1.1/ 400 Bad Request');
|
|
|
+ return $this->sendToClient(Man\Common\Protocols\Http\http_end('<h1>400 Bad Request</h1>'));
|
|
|
}
|
|
|
|
|
|
// 如果请求的是php文件
|
|
|
@@ -228,7 +228,7 @@ class WebServer extends Man\Core\SocketWorker
|
|
|
}
|
|
|
$content = ob_get_clean();
|
|
|
ini_set('display_errors', 'on');
|
|
|
- $buffer = App\Common\Protocols\Http\http_end($content);
|
|
|
+ $buffer = Man\Common\Protocols\Http\http_end($content);
|
|
|
$this->sendToClient($buffer);
|
|
|
// 执行php每执行一次就退出(原因是有的业务使用了require_once类似的语句,不能重复加载业务逻辑)
|
|
|
//return $this->stop();
|
|
|
@@ -238,11 +238,11 @@ class WebServer extends Man\Core\SocketWorker
|
|
|
// 请求的是静态资源文件
|
|
|
if(isset(self::$mimeTypeMap[$extension]))
|
|
|
{
|
|
|
- App\Common\Protocols\Http\header('Content-Type: '. self::$mimeTypeMap[$extension]);
|
|
|
+ Man\Common\Protocols\Http\header('Content-Type: '. self::$mimeTypeMap[$extension]);
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
- App\Common\Protocols\Http\header('Content-Type: '. self::$defaultMimeType);
|
|
|
+ Man\Common\Protocols\Http\header('Content-Type: '. self::$defaultMimeType);
|
|
|
}
|
|
|
|
|
|
// 获取文件信息
|
|
|
@@ -257,9 +257,9 @@ class WebServer extends Man\Core\SocketWorker
|
|
|
if($modified_time === $_SERVER['HTTP_IF_MODIFIED_SINCE'])
|
|
|
{
|
|
|
// 304
|
|
|
- App\Common\Protocols\Http\header('HTTP/1.1 304 Not Modified');
|
|
|
+ Man\Common\Protocols\Http\header('HTTP/1.1 304 Not Modified');
|
|
|
// 发送给客户端
|
|
|
- return $this->sendToClient(App\Common\Protocols\Http\http_end(''));
|
|
|
+ return $this->sendToClient(Man\Common\Protocols\Http\http_end(''));
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@@ -286,17 +286,17 @@ class WebServer extends Man\Core\SocketWorker
|
|
|
|
|
|
if($modified_time)
|
|
|
{
|
|
|
- App\Common\Protocols\Http\header("Last-Modified: $modified_time");
|
|
|
+ Man\Common\Protocols\Http\header("Last-Modified: $modified_time");
|
|
|
}
|
|
|
|
|
|
// 发送给客户端
|
|
|
- return $this->sendToClient(App\Common\Protocols\Http\http_end($file_content));
|
|
|
+ return $this->sendToClient(Man\Common\Protocols\Http\http_end($file_content));
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
// 404
|
|
|
- App\Common\Protocols\Http\header("HTTP/1.1 404 Not Found");
|
|
|
- return $this->sendToClient(App\Common\Protocols\Http\http_end('<html><head><title>页面不存在</title></head><body><center><h3>页面不存在</h3></center></body></html>'));
|
|
|
+ Man\Common\Protocols\Http\header("HTTP/1.1 404 Not Found");
|
|
|
+ return $this->sendToClient(Man\Common\Protocols\Http\http_end('<html><head><title>页面不存在</title></head><body><center><h3>页面不存在</h3></center></body></html>'));
|
|
|
}
|
|
|
}
|
|
|
|