public function getLocation($uri) { $request = new Request('http://' . self::DOMAIN . '/' . $uri); $request->execute(); $location = $request->getResponse()->headers->get('location'); if (!$location) { throw new URIException('No "Location" header found'); } else { if ($location == '/') { throw new URIException(); } else { return $location; } } }
/** * @param string $url The URL of the gzip * @return string the uncompressed downloaded content * @throws Curl\Exception\ProtectedOptionException * @throws GoogleSitemapParserException */ protected function downloadAndExtractGZIP($url) { try { $request = new Request($url); $request->setOption(CURLOPT_ENCODING, ''); $request->execute(); /** @var \Symfony\Component\HttpFoundation\Response $response */ $response = $request->getResponse(); return $response->headers->get('Content-Type') === 'application/xml' ? $response->getContent() : gzdecode($response->getContent()); } catch (Curl\Exception\CurlErrorException $e) { throw new GoogleSitemapParserException($e->getMessage()); } }
/** * @expectedException jyggen\Curl\Exception\CurlErrorException * @expectedExceptionMessage curl_multi */ public function testAddMultiHandleWithInvalidHandle() { $request = new Request('http://example.com/'); $this->assertTrue($request->addMultiHandle('lolnope')); }