/**
  * Intercept begins the detection and returns the snapshot if the request was scraped.
  * 
  * @return array|boolean
  */
 public function intercept()
 {
     if ($this->detector->detect()) {
         $raw_current_url = $this->detector->get_encoded_url();
         //call the before interceptor and return an array response if it has one
         $before_intercept = $this->before;
         if ($before_intercept) {
             $result = $before_intercept($raw_current_url);
             if (is_array($result)) {
                 return $result;
             }
         }
         $response = $this->client->request($raw_current_url);
         //call the after response interceptor, and pass in the $response array (which is always going to be an array)
         $after_intercept = $this->after;
         if ($after_intercept) {
             $after_intercept($raw_current_url, $response);
         }
         return $response;
     }
     return false;
 }
 public function testEscapedFragmentRouteShouldBeConvertedBackToHashFragment()
 {
     $request = new Request(array('key1' => 'value1', '_escaped_fragment_' => '/path2?key2=value2'), $_POST, array(), $_COOKIE, $_FILES, array('HTTP_HOST' => 'localhost', 'HTTP_USER_AGENT' => 'Mozilla/5.0 (Windows NT 6.2; WOW64; rv:25.0) Gecko/20100101 Firefox/25.0', 'SERVER_NAME' => 'localhost', 'SERVER_PORT' => '80', 'REMOTE_ADDR' => '::1', 'DOCUMENT_ROOT' => 'C:/www', 'REQUEST_SCHEME' => 'http', 'GATEWAY_INTERFACE' => 'CGI/1.1', 'SERVER_PROTOCOL' => 'HTTP/1.1', 'REQUEST_METHOD' => 'GET', 'QUERY_STRING' => 'key1=value1&_escaped_fragment_=%2Fpath2%3Fkey2=value2', 'REQUEST_URI' => '/snapsearch/path1?key1=value1&_escaped_fragment_=%2Fpath2%3Fkey2=value2'));
     $detector = new Detector(null, null, false, $request);
     $this->assertEquals($detector->get_encoded_url(), 'http://localhost/snapsearch/path1?key1=value1#!/path2?key2=value2');
 }