Add support for X-HTTP-Method-Override header

remotes/remote_mirror_8/master
Mike Koch 7 years ago
parent a4836f1142
commit 3aea482c3c

@ -39,7 +39,7 @@ class Link
} }
self::$routes = $routes; self::$routes = $routes;
$method = strtolower($_SERVER['REQUEST_METHOD']); $method = self::getRequestMethod();
$path = '/'; $path = '/';
$handler = null; $handler = null;
$matched = array(); $matched = array();
@ -108,6 +108,21 @@ class Link
} }
} }
private static function getRequestMethod() {
$headers = getallheaders();
$uppercaseHeaders = array();
foreach ($headers as $header => $value) {
$uppercaseHeaders[strtoupper($header)] = $value;
}
if (isset($uppercaseHeaders['X-HTTP-METHOD-OVERRIDE'])) {
return $uppercaseHeaders['X-HTTP-METHOD-OVERRIDE'];
}
return $_SERVER['REQUEST_METHOD'];
}
/** /**
* Static function that helps you generate links effortlessly and pass parameters to them, thus enabling to generate dynamic links * Static function that helps you generate links effortlessly and pass parameters to them, thus enabling to generate dynamic links
* *

Loading…
Cancel
Save