ENHANCEMENT allow Director::test() to cope with absolute URIs

git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/trunk@81680 467b73ca-7a2a-4603-9d3b-597d59a354a9
This commit is contained in:
Tom Rix 2009-07-13 04:15:40 +00:00
parent 6a52153b9f
commit 39309b1e9a

View File

@ -179,12 +179,6 @@ class Director {
if(!$httpMethod) $httpMethod = ($postVars || is_array($postVars)) ? "POST" : "GET";
$urlWithQuerystring = $url;
if(strpos($url, '?') !== false) {
list($url, $getVarsEncoded) = explode('?', $url, 2);
parse_str($getVarsEncoded, $getVars);
}
if(!$session) $session = new Session(null);
// Back up the current values of the superglobals
@ -200,6 +194,19 @@ class Director {
Cookie::set_report_errors(false);
Requirements::set_backend(new Requirements_Backend());
// Handle absolute URLs
if (@parse_url($url, PHP_URL_HOST) != '') {
$bits = parse_url($url);
$_SERVER['HTTP_HOST'] = $bits['host'];
$url = Director::makeRelative($url);
}
$urlWithQuerystring = $url;
if(strpos($url, '?') !== false) {
list($url, $getVarsEncoded) = explode('?', $url, 2);
parse_str($getVarsEncoded, $getVars);
}
// Replace the superglobals with appropriate test values
$_REQUEST = array_merge((array)$getVars, (array)$postVars);
$_GET = (array)$getVars;