本文整理汇总了PHP中Sabre_HTTP_Request::getRawServerValue方法的典型用法代码示例。如果您正苦于以下问题:PHP Sabre_HTTP_Request::getRawServerValue方法的具体用法?PHP Sabre_HTTP_Request::getRawServerValue怎么用?PHP Sabre_HTTP_Request::getRawServerValue使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Sabre_HTTP_Request
的用法示例。
在下文中一共展示了Sabre_HTTP_Request::getRawServerValue方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: guessBaseUri
/**
* This method attempts to detect the base uri.
* Only the PATH_INFO variable is considered.
*
* If this variable is not set, the root (/) is assumed.
*
* @return string
*/
public function guessBaseUri()
{
$pathInfo = $this->httpRequest->getRawServerValue('PATH_INFO');
$uri = $this->httpRequest->getRawServerValue('REQUEST_URI');
// If PATH_INFO is found, we can assume it's accurate.
if (!empty($pathInfo)) {
// We need to make sure we ignore the QUERY_STRING part
if ($pos = strpos($uri, '?')) {
$uri = substr($uri, 0, $pos);
}
// PATH_INFO is only set for urls, such as: /example.php/path
// in that case PATH_INFO contains '/path'.
// Note that REQUEST_URI is percent encoded, while PATH_INFO is
// not, Therefore they are only comparable if we first decode
// REQUEST_INFO as well.
$decodedUri = Sabre_DAV_URLUtil::decodePath($uri);
// A simple sanity check:
if (substr($decodedUri, strlen($decodedUri) - strlen($pathInfo)) === $pathInfo) {
$baseUri = substr($decodedUri, 0, strlen($decodedUri) - strlen($pathInfo));
return rtrim($baseUri, '/') . '/';
}
throw new Sabre_DAV_Exception('The REQUEST_URI (' . $uri . ') did not end with the contents of PATH_INFO (' . $pathInfo . '). This server might be misconfigured.');
}
// The last fallback is that we're just going to assume the server root.
return '/';
}