Example #1
0
 /**
  * match(): defined by Route interface
  *
  * @see    Route::match()
  * @param  HttpRequest $request
  * @param  integer     $pathOffset
  * @return boolean
  */
 public function match(HttpRequest $request, $pathOffset = null)
 {
     if ($pathOffset !== null) {
         $result = preg_match('(\\G' . $this->_regex . ')i', $request->getRequestUri(), $match, null, $pathOffset);
     } else {
         $result = preg_match('(^' . $this->_regex . '$)i', $request->getRequestUri(), $match);
     }
     if ($result === null) {
         return null;
     }
     // @todo: examine $match
     return $this->_defaults;
 }
Example #2
0
 /**
  * match(): defined by Route interface
  *
  * @see    Route::match()
  * @param  HttpRequest $request
  * @param  integer     $pathOffset
  * @return boolean
  */
 public function match(HttpRequest $request, $pathOffset = null)
 {
     if ($pathOffset !== null) {
         if (strpos($request->getRequestUri(), $this->_route) === $pathOffset) {
             return $this->_defaults;
         }
     } else {
         if ($request->getRequestUri() === $this->_route) {
             return $this->_defaults;
         }
     }
     return null;
 }
Example #3
0
 /**
  * @group ZF-3161
  * @group ZFI-233
  * @group ZF-5818
  */
 public function testStrippingHttpProtocolHostAndNonStandardPortFromRequestUriOnlyWhenPresentAtBeginningOfUri()
 {
     $_SERVER['REQUEST_URI'] = 'http://foo.example.com:8888/foo/bar?r=http://foo.example.com:8888/bar/baz';
     $_SERVER['HTTP_HOST'] = '';
     $_SERVER['SERVER_NAME'] = 'foo.example.com';
     $_SERVER['SERVER_PORT'] = '8888';
     $request = new Request\Http();
     $test = $request->getRequestUri();
     $this->assertEquals('/foo/bar?r=http://foo.example.com:8888/bar/baz', $test);
     $_SERVER['REQUEST_URI'] = '/foo/bar?r=https://foo.example.com:8888/bar/baz';
     $_SERVER['HTTP_HOST'] = '';
     $_SERVER['SERVER_NAME'] = 'foo.example.com';
     $_SERVER['SERVER_PORT'] = '8888';
     $request = new Request\Http();
     $test = $request->getRequestUri();
     $this->assertEquals('/foo/bar?r=https://foo.example.com:8888/bar/baz', $test);
 }