/** * 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 testSettingTheExtensionsArray() { $request = new Request($_GET, $_POST, array(), $_COOKIE, $_FILES, array('HTTP_HOST' => 'localhost', 'HTTP_USER_AGENT' => 'AdsBot-Google ( http://www.google.com/adsbot.html)', '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' => '', 'REQUEST_URI' => '/snapsearch/song.html.mp3?key=value')); $detector = new Detector(null, null, true, $request); $detector->extensions['generic'][] = 'mp3'; $this->assertTrue($detector->detect()); }