Permalink
Browse files

mod_dir is working properly with the subrequest method

  • Loading branch information...
1 parent e2ba463 commit fadcd323e2082d21f3d4a3dc0a2b7908422e9749 @jaytaph committed Jan 18, 2012
Showing with 30 additions and 30 deletions.
  1. +6 −7 TODO
  2. +0 −17 htrouter/HTRouter.php
  3. +24 −6 htrouter/Module/Dir.php
View
13 TODO
@@ -1,10 +1,9 @@
[.] Fix module mod_rewrite
-[ ] Add default fallback module for authentication (really needed?)
-[ ] Trimming should be done by config parser, not the actual modules
-[ ] refactor explode() into preg_split() (why is that again?)
-[ ] Correct path-info when dealing with apache router.php and uri: /router.php/test/blaat.php/this/is/pathinfo?debug
[ ] Remove subrequests. We don't use them (maybe dir.c uses it?)
[ ] Condition / _expandTestString needs to be fixed
-[ ] When merging variables, we should have an additional parameter specifying on what to merge (from a method inside module?)
-[ ] Remove subrequests. We don't use them
-[ ] In directives, do we need \HTRouter\Request $request or does the variableContainer (getConfig()) suffice?)
+[ ] Correct path-info when dealing with apache router.php and uri: /router.php/test/blaat.php/this/is/pathinfo?debug
+
+[ ] In directives, do we need \HTRouter\Request $request or does the variableContainer (getConfig()) suffice?)
+[ ] refactor explode() into preg_split() (why is that again?)
+[ ] Add default fallback module for authentication (really needed?)
+[ ] Trimming should be done by config parser, not the actual modules
View
@@ -105,7 +105,6 @@ private function __construct() {
$this->_populateInitialRequest($request);
}
-
/**
* This is the main entrypoint that routes everything. The module hooks will take care of finding
* and parsing .htaccess files correctly (i hope).
@@ -657,22 +656,6 @@ function unsetEnvironment($key) {
}
-// function prepareContainerForSubRequest($url) {
-// $subrequest = clone ($this->_container->getRequest());
-// $subrequest->setMainRequest(false);
-// $subrequest->setUri($url);
-// $subrequest->setFilename(null);
-//
-// $subContainer = clone ($this->_container);
-// //$subContainer->name = $this->_container->name . " (SubRequest)";
-// //$subContainer->setConfig($this->_container->getRouter()->getDefaultConfig());
-// $subContainer->setRequest($subrequest);
-//
-//
-// return $subContainer;
-// }
-
-
function getServerSoftware() {
return self::SERVER_SOFTWARE;
}
View
@@ -60,7 +60,8 @@ protected function _fixup_dflt(\HTRouter\Request $request) {
// In case a subrequest throws an error
$error_notfound = false;
- $subContainer = $this->getRouter()->prepareContainerForSubRequest($url);
+ // @TODO: Sub requests are done more often, we should move this to doSubRequest() in \HTRouter
+ $subContainer = $this->_prepareContainerForSubRequest($url);
$processor = new \HTRouter\Processor($subContainer);
$status = $processor->processRequest();
$subrequest = $subContainer->getRequest();
@@ -95,9 +96,8 @@ protected function _fixup_dflt(\HTRouter\Request $request) {
protected function _fixup_dir(\HTRouter\Request $request) {
$utils = new \HTRouter\Utils;
- $url = $request->getUri();
-
// Check if it doesn't end on a slash?
+ $url = $request->getUri();
if (!empty($url) and ($url[strlen($url)-1] != '/')) {
// We are fixing a directory and we aren't allowed to add a slash. No good.
if ($this->getConfig()->get("DirectorySlash") == false) {
@@ -123,7 +123,7 @@ protected function _fixup_dir(\HTRouter\Request $request) {
foreach ($names as $name) {
$url = $this->_updateUrl($request->getUri(), $name);
- $subContainer = $this->getRouter()->prepareContainerForSubRequest($url);
+ $subContainer = $this->_prepareContainerForSubRequest($url);
$processor = new \HTRouter\Processor($subContainer);
$status = $processor->processRequest();
$subrequest = $subContainer->getRequest();
@@ -159,7 +159,9 @@ public function dirFixups(\HTRouter\Request $request) {
if (empty($filename) || is_dir($request->getDocumentRoot() . $filename)) {
return $this->_fixup_dir($request);
- } elseif (! empty($filename) && ! file_exists($request->getDocumentRoot() . $filename)) { // @TODO: This must be different FILE_NOT_EXIST
+ } elseif (! empty($filename) && ! file_exists($request->getDocumentRoot() . $filename) &&
+ @filetype($request->getDocumentRoot() . $filename) == "unknown"
+ ) { // @TODO: This must be different FILE_NOT_EXIST
return $this->_fixup_dflt($request);
}
@@ -180,8 +182,24 @@ protected function _updateUrl($url, $path) {
return $url;
}
+
+ protected function _prepareContainerForSubRequest($url) {
+ $subrequest = clone ($this->_container->getRequest());
+ $subrequest->setMainRequest(false);
+ $subrequest->setUri($url);
+ $subrequest->setFilename(null);
+
+ $subContainer = clone ($this->_container);
+ //$subContainer->name = $this->_container->name . " (SubRequest)";
+ //$subContainer->setConfig($this->_container->getRouter()->getDefaultConfig());
+ $subContainer->setRequest($subrequest);
+
+ return $subContainer;
+ }
+
+
public function getAliases() {
- return array("mod_dir.c", "mod_dir");
+ return array("mod_dir.c", "mod_dir", "dir");
}
}

0 comments on commit fadcd32

Please sign in to comment.