本文整理汇总了PHP中Zend\Http\Request::uri方法的典型用法代码示例。如果您正苦于以下问题:PHP Request::uri方法的具体用法?PHP Request::uri怎么用?PHP Request::uri使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Zend\Http\Request
的用法示例。
在下文中一共展示了Request::uri方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testRequestCanSetAndRetrieveUri
public function testRequestCanSetAndRetrieveUri()
{
$request = new Request();
$request->setUri('/foo');
$this->assertEquals('/foo', $request->getUri());
$this->assertInstanceOf('Zend\\Uri\\Uri', $request->uri());
$this->assertEquals('/foo', $request->uri()->toString());
$this->assertEquals('/foo', $request->getUri());
}
示例2: _parseDigestAuth
/**
* Parse Digest Authorization header
*
* @param string $header Client's Authorization: HTTP header
* @return array|false Data elements from header, or false if any part of
* the header is invalid
*/
protected function _parseDigestAuth($header)
{
$temp = null;
$data = array();
// See ZF-1052. Detect invalid usernames instead of just returning a
// 400 code.
$ret = preg_match('/username="([^"]+)"/', $header, $temp);
if (!$ret || empty($temp[1])
|| !ctype_print($temp[1])
|| strpos($temp[1], ':') !== false) {
$data['username'] = '::invalid::';
} else {
$data['username'] = $temp[1];
}
$temp = null;
$ret = preg_match('/realm="([^"]+)"/', $header, $temp);
if (!$ret || empty($temp[1])) {
return false;
}
if (!ctype_print($temp[1]) || strpos($temp[1], ':') !== false) {
return false;
} else {
$data['realm'] = $temp[1];
}
$temp = null;
$ret = preg_match('/nonce="([^"]+)"/', $header, $temp);
if (!$ret || empty($temp[1])) {
return false;
}
if (!ctype_xdigit($temp[1])) {
return false;
} else {
$data['nonce'] = $temp[1];
}
$temp = null;
$ret = preg_match('/uri="([^"]+)"/', $header, $temp);
if (!$ret || empty($temp[1])) {
return false;
}
// Section 3.2.2.5 in RFC 2617 says the authenticating server must
// verify that the URI field in the Authorization header is for the
// same resource requested in the Request Line.
$rUri = $this->_request->uri();
$cUri = UriFactory::factory($temp[1]);
// Make sure the path portion of both URIs is the same
if ($rUri->getPath() != $cUri->getPath()) {
return false;
}
// Section 3.2.2.5 seems to suggest that the value of the URI
// Authorization field should be made into an absolute URI if the
// Request URI is absolute, but it's vague, and that's a bunch of
// code I don't want to write right now.
$data['uri'] = $temp[1];
$temp = null;
$ret = preg_match('/response="([^"]+)"/', $header, $temp);
if (!$ret || empty($temp[1])) {
return false;
}
if (32 != strlen($temp[1]) || !ctype_xdigit($temp[1])) {
return false;
} else {
$data['response'] = $temp[1];
}
$temp = null;
// The spec says this should default to MD5 if omitted. OK, so how does
// that square with the algo we send out in the WWW-Authenticate header,
// if it can easily be overridden by the client?
$ret = preg_match('/algorithm="?(' . $this->_algo . ')"?/', $header, $temp);
if ($ret && !empty($temp[1])
&& in_array($temp[1], $this->_supportedAlgos)) {
$data['algorithm'] = $temp[1];
} else {
$data['algorithm'] = 'MD5'; // = $this->_algo; ?
}
$temp = null;
// Not optional in this implementation
$ret = preg_match('/cnonce="([^"]+)"/', $header, $temp);
if (!$ret || empty($temp[1])) {
return false;
}
if (!ctype_print($temp[1])) {
return false;
} else {
$data['cnonce'] = $temp[1];
//.........这里部分代码省略.........
示例3: match
/**
* match(): defined by Route interface.
*
* @see Route::match()
* @param Request $request
* @return RouteMatch
*/
public function match(Request $request, $pathOffset = null)
{
$uri = $request->uri();
$path = $uri->getPath();
if ($pathOffset !== null) {
if (strpos($path, $this->route) === $pathOffset) {
return new RouteMatch($this->defaults, $this);
}
} else {
if ($path === $this->route) {
return new RouteMatch($this->defaults, $this);
}
}
return null;
}
示例4: match
/**
* match(): defined by Route interface.
*
* @see Route::match()
* @param Request $request
* @return RouteMatch
*/
public function match(Request $request, $pathOffset = null)
{
$uri = $request->uri();
$path = $uri->getPath();
if ($pathOffset !== null) {
$result = preg_match('#\G' . $this->regex . '#i', $path, $match, null, $pathOffset);
} else {
$result = preg_match('#^' . $this->regex . '$#i', $path, $match);
}
if (!$result) {
return null;
}
foreach ($match as $key => $value) {
if (is_numeric($key) || is_int($key)) {
unset($match[$key]);
}
}
$matches = array_merge($this->defaults, $match);
$this->matches = $matches;
return new RouteMatch($matches, $this);
}