Skip to content
Permalink
Browse files

Merge branch 'develop'

  • Loading branch information...
parkerj committed Oct 4, 2016
2 parents a856270 + 9c0b931 commit 5cfdf45810dfb6a09826b08cd5a48ce2960972d1
Showing with 17 additions and 16 deletions.
  1. +3 −3 Liten/Http/Request.php
  2. +10 −10 Liten/Liten.php
  3. +4 −3 index.php
@@ -75,7 +75,7 @@ public function disableSSL()
public function getMethod()
{
return $this->server['REQUEST_METHOD'];
return $_SERVER['REQUEST_METHOD'];
}
/**
@@ -146,7 +146,7 @@ public function isOptions()
*/
public function getHost()
{
return $this->server['HTTP_HOST'];
return $_SERVER['HTTP_HOST'];
}
/**
@@ -166,7 +166,7 @@ public function protocol()
*/
public function url_for($route)
{
$base = $this->server['HTTP_HOST'] . $this->server['SCRIPT_NAME'];
$base = $_SERVER['HTTP_HOST'] . $_SERVER['SCRIPT_NAME'];
$index = str_replace('index.php', '', $base);
$url = rtrim($index, '/');
@@ -34,7 +34,7 @@ class Liten
/**
* @var string
*/
public $version = '1.0.6';
public $version = '1.0.7';
/**
* @var \Liten\Helper\Set
@@ -388,7 +388,7 @@ public function getRequestHeaders()
// getallheaders not available: manually extract 'm
$headers = [];
foreach ($this->req->server as $name => $value) {
foreach ($_SERVER as $name => $value) {
if ((substr($name, 0, 5) == 'HTTP_') || ($name == 'CONTENT_TYPE') || ($name == 'CONTENT_LENGTH')) {
$headers[str_replace([' ', 'Http'], ['-', 'HTTP'], ucwords(strtolower(str_replace('_', ' ', substr($name, 5)))))] = $value;
}
@@ -403,15 +403,15 @@ public function getRequestHeaders()
public function getRequestMethod()
{
// Take the method as found in $_SERVER
$method = $this->req->server['REQUEST_METHOD'];
$method = $_SERVER['REQUEST_METHOD'];
// If it's a HEAD request override it to being GET and prevent any output, as per HTTP Specification
// @url http://www.w3.org/Protocols/rfc2616/rfc2616-sec9.html#sec9.4
if ($this->req->server['REQUEST_METHOD'] == 'HEAD') {
if ($_SERVER['REQUEST_METHOD'] == 'HEAD') {
ob_start();
$method = 'GET';
}
// If it's a POST request, check for a method override header
else if ($this->req->server['REQUEST_METHOD'] == 'POST') {
else if ($_SERVER['REQUEST_METHOD'] == 'POST') {
$headers = $this->getRequestHeaders();
if (isset($headers['X-HTTP-Method-Override']) && in_array($headers['X-HTTP-Method-Override'], ['PUT', 'DELETE', 'PATCH'])) {
$method = $headers['X-HTTP-Method-Override'];
@@ -441,15 +441,15 @@ public function run($callback = null)
if ($this->_error && is_callable($this->_error))
call_user_func($this->_error);
else
header($this->req->server['SERVER_PROTOCOL'] . ' 404 Not Found');
header($_SERVER['SERVER_PROTOCOL'] . ' 404 Not Found');
}
// If a route was handled, perform the finish callback (if any)
else {
if ($callback)
$callback();
}
// If it originally was a HEAD request, clean up after ourselves by emptying the output buffer
if ($this->req->server['REQUEST_METHOD'] == 'HEAD')
if ($_SERVER['REQUEST_METHOD'] == 'HEAD')
ob_end_clean();
}
@@ -516,7 +516,7 @@ private function handle($routes, $quitAfterRun = false)
public function prefixHost($resourcePath, $hostType = null)
{
if ($hostType == BASE_URL || is_null($hostType) || APP_ENV != 'PROD') {
return "//" . $this->req->server['HTTP_HOST'] . $resourcePath;
return "//" . $_SERVER['HTTP_HOST'] . $resourcePath;
}
return "//" . $hostType . $resourcePath;
}
@@ -528,8 +528,8 @@ public function prefixHost($resourcePath, $hostType = null)
private function getCurrentUri()
{
// Get the current Request URI and remove rewrite basepath from it (= allows one to run the router in a subfolder)
$basepath = implode('/', array_slice(explode('/', $this->req->server['SCRIPT_NAME']), 0, -1)) . '/';
$uri = substr($this->req->server['REQUEST_URI'], strlen($basepath));
$basepath = implode('/', array_slice(explode('/', $_SERVER['SCRIPT_NAME']), 0, -1)) . '/';
$uri = substr($_SERVER['REQUEST_URI'], strlen($basepath));
// Don't take query params into account on the URL
if (strstr($uri, '?'))
$uri = substr($uri, 0, strpos($uri, '?'));
@@ -27,7 +27,6 @@
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
/**
* Step 1: Require the Bootstrap
*
@@ -156,13 +155,15 @@
);
// POST route
$app->post('/post', function () {
$app->post(
'/post', function () {
echo 'Example of a post route.';
}
);
// DELETE route
$app->delete('/delete', function () {
$app->delete(
'/delete', function () {
echo 'Example of a delete route.';
}
);

0 comments on commit 5cfdf45

Please sign in to comment.
You can’t perform that action at this time.