public function test_get() { $config = new \Imdb\Config(); $request = new Request('https://images-na.ssl-images-amazon.com/images/M/MV5BMDMyMmQ5YzgtYWMxOC00OTU0LWIwZjEtZWUwYTY5MjVkZjhhXkEyXkFqcGdeQXVyNDYyMDk5MTU@._V1_UY268_CR6,0,182,268_AL_.jpg', $config); $ok = $request->sendRequest(); $this->assertTrue($ok); $headers = $request->getLastResponseHeaders(); $this->assertTrue(count($headers) > 5); $this->assertEquals($request->getresponseheader('Content-Type'), 'image/jpeg'); }
/** Convert IMDB redirect-URLs of external sites to real URLs * @method convertIMDBtoRealURL * @param string url redirect-url * @return string url real-url */ protected function convertIMDBtoRealURL($url) { if (preg_match('/^https?:\\/\\//', $url)) { return $url; } $req = new Request("http://" . $this->imdbsite . $url, $this->config); if ($req->sendRequest() !== FALSE) { $head = $req->getLastResponseHeaders(); foreach ($head as $header) { if (preg_match('/:/', $header)) { list($type, $value) = explode(':', $header, 2); if ($type == 'Location') { return preg_replace('/\\s/', '', $value); } } } } return false; }