Exemple #1
0
 /**
  * @return void
  */
 public function next()
 {
     $this->load();
     if ($url = static::parseLink($this->response->getHeader('Link'), 'next')) {
         $this->request = new Http\Request($this->request->getMethod(), $url, $this->request->getHeaders(), $this->request->getContent());
     } else {
         $this->request = NULL;
     }
     $this->response = NULL;
     $this->counter++;
 }
Exemple #2
0
 /**
  *  Initiate the routing for the given URL
  */
 public static function route(Http\Request $request)
 {
     $path = $request->REQUEST_URI;
     $key = $request->getMethod() . '@' . $path;
     $keyAny = 'ANY@' . $path;
     $matchedRoute = null;
     $matchedScore = 0;
     if (isset(self::$routes[$key])) {
         $matchedRoute = self::$routes[$key];
     } elseif (isset(self::$routes[$keyAny])) {
         $matchedRoute = self::$routes[$keyAny];
     } else {
         foreach (self::$routes as $key2 => $route) {
             if ($route->getMethod() != 'ANY' && $route->getMethod() != $request->getMethod()) {
                 continue;
             }
             $score = $route->getScore($path, $request->getMethod());
             if ($score > $matchedScore) {
                 $matchedRoute = $route;
                 $matchedScore = $score;
             }
         }
     }
     if ($matchedRoute) {
         $matchedRoute->setUrl($path);
     } elseif (self::$_404route) {
         $matchedRoute = self::$_404route;
     } else {
         throw new Exceptions\RouteException('Route not found');
     }
     return $matchedRoute;
 }