Exemplo n.º 1
0
 /**
  * Overrides match to detect port
  *
  * @param Zend_Controller_Request_Http $request
  * @return array|false
  */
 public function match($request)
 {
     if ($this->hasPort()) {
         // Check that the port matches the route port
         $host = $request->getHttpHost();
         if (preg_match(self::PORT_REGEXP, $host, $m)) {
             $port = (int) $m[1];
         } else {
             // Assign a default port according to the scheme
             $port = $request->isSecure() ? 443 : 80;
         }
         if ($port !== (int) $this->getPort()) {
             return false;
         }
     }
     // Default match
     return parent::match($request);
 }
Exemplo n.º 2
0
 public function testSchemeNoMatch()
 {
     $request = new Zend_Controller_Router_RewriteTest_Request_Stub('www.zend.com', 'http');
     $route = new Zend_Controller_Router_Route_Hostname('www.zend.com', array('controller' => 'host-foo', 'action' => 'host-bar'), array(), 'https');
     $values = $route->match($request);
     $this->assertFalse($values);
 }
Exemplo n.º 3
0
 public function testRouteWithHostname()
 {
     $_SERVER['SERVER_NAME'] = 'www.zend.com';
     $request = new Zend_Controller_Router_RewriteTest_Request_Stub('www.zend.com');
     $route = new Zend_Controller_Router_Route_Hostname('www.zend.com', array('controller' => 'host-foo', 'action' => 'host-bar'));
     $values = $route->match($request);
     $this->assertEquals('host-foo', $values['controller']);
     $this->assertEquals('host-bar', $values['action']);
 }