therselman 7 years ago
parent
commit
bb8dfaad6b
  1. 20
      src/Twister/Request.php
  2. 2
      src/Twister/Response.php

20
src/Twister/Request.php

@ -396,16 +396,16 @@ class Request @@ -396,16 +396,16 @@ class Request
if ($parts === '' || $parts === '//')
return $this->uri->withScheme(null); // '//' . $this->uri->authority . $this->uri->getPathAndQuery();
if ($parts[0] === '/')
return $this->uri->getLeftPart(Uri::PARTIAL_AUTHORITY) . $parts; //(_::is_https() ? 'https://' : 'http://') . _::request('host') . $parts;
return $this->uri->getLeftPart(Uri::PARTIAL_AUTHORITY) . $parts; // (_::is_https() ? 'https://' : 'http://') . _::request('host') . $parts;
if ($parts === 'https' || $parts === 'http')
return $this->uri->withScheme($parts); //$parts . '://' . _::request('host') . _::request('uri');
return $this->uri->withScheme($parts); // $parts . '://' . _::request('host') . _::request('uri');
if ($parts[0] === '?')
return $this->uri->getLeftPart(Uri::PARTIAL_PATH) . $parts; //(_::is_https() ? 'https://' : 'http://') . _::request('host') . _::request('path') . $parts;
return $this->uri->getLeftPart(Uri::PARTIAL_PATH) . $parts; // (_::is_https() ? 'https://' : 'http://') . _::request('host') . _::request('path') . $parts;
if (strpos($parts, '=') !== false)
return $this->uri->getLeftPart(Uri::PARTIAL_PATH) . '?' . $parts; // (_::is_https() ? 'https://' : 'http://') . _::request('host') . _::request('path') . '?' . $parts;
if ($parts[0] === '#')
return $this->uri->withFragment($parts); // (_::is_https() ? 'https://' : 'http://') . _::request('host') . _::request('uri') . $parts;
die('Invalid call to Request::build_url("' . $parts . '")');
throw new \Exception("Invalid call to Request::build_url('{$parts}')");
}
return (string) (new Uri($parts));
/*
@ -472,12 +472,12 @@ class Request @@ -472,12 +472,12 @@ class Request
$location = $arg; // $arg == 'http://www.google.com/'
break;
case '?':
$location = $this->uri->getLeftPart(Uri::PARTIAL_PATH) . $parts; //(_::is_https() ? 'https://' : 'http://') . _::request('host') . _::request('path') . $parts;
$location = $this->uri->getLeftPart(Uri::PARTIAL_PATH) . $parts; // (_::is_https() ? 'https://' : 'http://') . _::request('host') . _::request('path') . $parts;
//$location = _::request('path') . $arg;
break;
case '&': // append to query string
$location = $this->uri->getLeftPart(Uri::PARTIAL_QUERY);
$location .= (strpos($location, '?') === false ? '?' . substr($arg, 1) : $arg);
$location .= strpos($location, '?') === false ? '?' . substr($arg, 1) : $arg;
// $location .= ($location->query === null ? '?' . substr($arg, 1) : $arg); // alternative using Uri object!
//$location = _::request('uri') . (empty(_::request('query')) ? '?' . substr($arg, 1) : $arg);
break;
@ -612,8 +612,6 @@ class Request @@ -612,8 +612,6 @@ class Request
die('Invalid value in request::redirect(): ' . print_r($args, true));
}
die('redirecting to: <a href="' . $location . '">' . $location . '</a>');
// ob_get_length() will return "FALSE if no buffering is active." ... so all we want to know is if buffering IS active AND there was already data sent to the buffer ... then we need to die()!
if (ob_get_length()) die(ob_get_clean() . '<p><span style="color: red;">Errors on Redirect to: <a href="' . $location . '">' . $location . '</a></span></p>');
if ( ! headers_sent($filename, $linenum))
@ -622,9 +620,7 @@ die('redirecting to: <a href="' . $location . '">' . $location . '</a>'); @@ -622,9 +620,7 @@ die('redirecting to: <a href="' . $location . '">' . $location . '</a>');
else echo '<p><span style="color: red"><b>ERROR: Empty location on redirect()!</b></span></p>';
exit;
}
die('<p><span style="color: red">ERROR:</span> <b>Headers already sent</b> in "' . $filename . '" on line <b>' . $linenum . '<br />' .
'Cannot redirect, please click the following link: <a href="' . $location . '">' . $location . '</a></p>');
throw new \Exception("<p><span style='color: red'>ERROR:</span> <b>Headers already sent</b> in `{$filename}` on line <b>`{$linenum}`<br />" .
"Cannot redirect, please click the following link: <a href='{$location}'>{$location}</a></p>");
}
}

2
src/Twister/Response.php

@ -100,7 +100,7 @@ class Response @@ -100,7 +100,7 @@ class Response
*/
function render()
{
call_user_func($this->renderer);
call_user_func($this->renderer, $this->container);
echo PHP_EOL,
'<!-- memory_get_usage(): ', number_format(memory_get_usage()), ' -->', PHP_EOL,

Loading…
Cancel
Save