Exemplo n.º 1
0
 public function testRequest()
 {
     $request = new Sabel_Request_Object();
     $request->get("index/index");
     $response = $this->request($request);
     $this->assertFalse($this->isRedirected($response));
 }
Exemplo n.º 2
0
 public function execute(Sabel_Bus $bus)
 {
     if ($bus->has("request")) {
         $request = $bus->get("request");
     } else {
         $uri = $this->getRequestUri($bus);
         $request = new Sabel_Request_Object($uri);
         if (SBL_SECURE_MODE) {
             $_GET = remove_nullbyte($_GET);
             $_POST = remove_nullbyte($_POST);
         }
         $request->setGetValues($_GET);
         $request->setPostValues($_POST);
         $this->setFiles($request);
         if (isset($_SERVER["REQUEST_METHOD"])) {
             $request->method($_SERVER["REQUEST_METHOD"]);
         }
         $httpHeaders = array();
         foreach ($_SERVER as $key => $val) {
             if (strpos($key, "HTTP") === 0) {
                 $httpHeaders[$key] = $val;
             }
         }
         $request->setHttpHeaders($httpHeaders);
         $bus->set("request", $request);
     }
     l("REQUEST URI: /" . $request->getUri(true));
     // Ajax request.
     if ($request->getHttpHeader("X-Requested-With") === "XMLHttpRequest") {
         $bus->set("NO_LAYOUT", true);
         $bus->set("IS_AJAX_REQUEST", true);
     }
 }
Exemplo n.º 3
0
 protected function routing($config)
 {
     $request = new Sabel_Request_Object("index/index");
     $config->configure();
     $candidate = $config->getValidCandidate($request->getUri());
     Sabel_Context::getContext()->setCandidate($candidate);
 }
Exemplo n.º 4
0
 protected function httpGet($uri, $session = null, $maxRedirects = 0)
 {
     $request = new Sabel_Request_Object(normalize_uri($uri));
     if (isset($parsedUrl["query"]) && !empty($parsedUrl["query"])) {
         parse_str($parsedUrl["query"], $get);
         $request->setGetValues($get);
     }
     return $this->request($request, $session, $maxRedirects);
 }
Exemplo n.º 5
0
 public function testSetRequestObject()
 {
     $bus = $this->bus;
     $request = new Sabel_Request_Object("");
     $request->setPostValue("hoge", "1");
     $bus->set("request", $request);
     $processor = new Processor_Request("request");
     $processor->execute($bus);
     $this->assertEquals("1", $bus->get("request")->fetchPostValue("hoge"));
 }
Exemplo n.º 6
0
 protected function httpGet($uri, $session = null, $maxRedirects = 0)
 {
     $uri = trim(preg_replace("@/{2,}@", "/", $uri, "/"));
     $parsedUrl = parse_url("http://localhost/{$uri}");
     $request = new Sabel_Request_Object(ltrim($parsedUrl["path"], "/"));
     if (isset($parsedUrl["query"]) && !empty($parsedUrl["query"])) {
         parse_str($parsedUrl["query"], $get);
         $request->setGetValues($get);
     }
     return $this->request($request, $session, $maxRedirects);
 }
Exemplo n.º 7
0
 public function testFindDuplicateValues()
 {
     $request = new Sabel_Request_Object("");
     $request->setGetValue("a", "10");
     $request->setPostValue("b", "20");
     $request->setParameterValue("b", "30");
     $this->assertEquals("10", $request->find("a"));
     try {
         $this->assertEquals("20", $request->find("b"));
     } catch (Exception $e) {
         return;
     }
     $this->fail();
 }