function testParamsAndPath()
 {
     $path = "/utenlandsbolig/spania/agentA/bolig12/?arg=tull&id=123";
     $parts = DF_Web_HTTP_Path::split_params($path);
     $new_path = $parts[0];
     $arguments = DF_Web_HTTP_Path::split_parts($new_path);
     $this->assertEqual(4, sizeof($arguments));
 }
Beispiel #2
0
 private function setup_request()
 {
     $env = DF_Web_Environment::singleton();
     $request = new DF_Web_HTTP_Request();
     $base_path = $this->base_path;
     $req_path = $_SERVER['REQUEST_URI'];
     $req_method = $_SERVER['REQUEST_METHOD'];
     $hostname = $_SERVER['HTTP_HOST'];
     $port = $_SERVER['SERVER_PORT'];
     if ($req_path && !DF_Web_HTTP_Path::has_base_path($req_path, $base_path)) {
         throw new DF_Web_Exception("Requested path ({$req_path}) does not contain base path: {$base_path}");
     }
     $req_path = DF_Web_HTTP_Path::strip_base_path($req_path, $base_path);
     $req_path = DF_Web_HTTP_Path::strip_query_params($req_path);
     $request->set_path($req_path);
     $request->set_base_path($base_path);
     list($path, $_jimbo) = DF_Web_HTTP_Path::split_params($req_path);
     $arguments = DF_Web_HTTP_Path::split_parts($path);
     $request->set_arguments($arguments);
     $request->set_hostname($hostname);
     $request->set_port($port);
     $request->set_method(strtolower($req_method));
     if (get_magic_quotes_gpc()) {
         DF_Web_HTTP_Request_MagicQuotes::stripslash_request();
     }
     if ($_POST) {
         $request->set_body_parameters($_POST);
     }
     if ($_COOKIE) {
         $request->set_cookies($_COOKIE);
     }
     if ($_GET) {
         $request->set_query_parameters($_GET);
     }
     if ($_FILES) {
         $request->set_uploads($_FILES);
     }
     $proxies = $env->trusted_proxies;
     $ipAddress = self::extract_client_address($proxies - 1);
     $request->set_address($ipAddress);
     # TODO how do we figure this out? probably not needed anyway
     $request->set_secure(false);
     $request->finalize();
     $this->request = $request;
     return true;
 }
Beispiel #3
0
 /**
  * @return array
  */
 public function get_path_parts()
 {
     $arr = DF_Web_HTTP_Path::split_parts($this->path . "");
     $parts = array();
     foreach ($arr as $str) {
         $part = DF_Web_Path_Part::fromString($str);
         $parts[] = $part;
     }
     return $parts;
 }