@@ -34,6 +34,8 @@ class WorkermanServer {
3434
3535 public $ onWorkerStart ;
3636
37+ private static $ uriInfos ;
38+
3739 /**
3840 *
3941 * @return int
@@ -120,11 +122,12 @@ protected function handle(ConnectionInterface $connection, $datas) {
120122 // $_REQUEST['REQUEST_TIME_FLOAT']=\microtime(true);
121123 Http::header ('Date: ' . \gmdate ('D, d M Y H:i:s ' ) . ' GMT ' );
122124 $ _GET ['c ' ] = '' ;
123- $ uri = \ltrim (\urldecode (\parse_url ($ _SERVER ['REQUEST_URI ' ], PHP_URL_PATH )), '/ ' );
124- if (($ uri == null || ! ($ fe = \file_exists ($ this ->basedir . '/../ ' . $ uri ))) && ($ uri != 'favicon.ico ' )) {
125+ $ uriInfos = (self ::$ uriInfos [$ _SERVER ['REQUEST_URI ' ]] ??= self ::parseURI ($ _SERVER ['REQUEST_URI ' ]));
126+ $ uri = $ uriInfos ['uri ' ];
127+ if ($ uriInfos ['isAction ' ]) {
125128 $ _GET ['c ' ] = $ uri ;
126129 } else {
127- if ($ fe ) {
130+ if ($ uriInfos [ ' fe ' ] ) {
128131 Http::header ('Content-Type: ' . (HttpCache::$ header ['Accept ' ] ?? 'text/html; charset=utf-8 ' ), true );
129132 return $ connection ->send (\file_get_contents ($ this ->basedir . '/../ ' . $ uri ));
130133 } else {
@@ -140,6 +143,16 @@ protected function handle(ConnectionInterface $connection, $datas) {
140143 return $ connection ->send (\ob_get_clean ());
141144 }
142145
146+ protected static function parseURI ($ requestURI ) {
147+ $ uri = \ltrim (\urldecode (\parse_url ($ requestURI , PHP_URL_PATH )), '/ ' );
148+ $ isAction = ($ uri == null || ! ($ fe = \file_exists ($ this ->basedir . '/../ ' . $ uri ))) && ($ uri != 'favicon.ico ' );
149+ return [
150+ 'uri ' => $ uri ,
151+ 'isAction ' => $ isAction ,
152+ 'file ' => $ fe
153+ ];
154+ }
155+
143156 /**
144157 * Sets the worker count
145158 *
0 commit comments