diff --git a/.php_cs.cache b/.php_cs.cache index bc6289f..fe50b86 100644 --- a/.php_cs.cache +++ b/.php_cs.cache @@ -1 +1 @@ -{"php":"7.2.10-0ubuntu0.18.04.1","version":"2.13.1","rules":{"array_syntax":{"syntax":"short"}},"hashes":{"src\/Response.php":1111513497,"src\/Helper.php":4165267782,"src\/Request.php":4238921734,"src\/UserAgentTrait.php":3411116384}} \ No newline at end of file +{"php":"7.2.10-0ubuntu0.18.04.1","version":"2.13.1","rules":{"array_syntax":{"syntax":"short"}},"hashes":{"src\/Response.php":3945040232,"src\/Helper.php":1188516494,"src\/Request.php":3518412128,"src\/UserAgentTrait.php":1134166595}} \ No newline at end of file diff --git a/README.md b/README.md index 54f7602..cf8adaa 100644 --- a/README.md +++ b/README.md @@ -27,8 +27,17 @@ $ composer require piedweb/curl Quick Example : ``` php - - +$url = 'https://piedweb.com'; +$request = new Request($url); +$request + ->setDefaultSpeedOptions(true) + ->setDownloadOnlyIf('text/html') + ->setDestkopUserAgent() +; +$result = $request->exec(); +if ($result instanceof \PiedWeb\Curl\Response) { + $content = $this->getContent(); +} ``` All methods : diff --git a/src/Request.php b/src/Request.php index b5c1232..e9a7ee1 100644 --- a/src/Request.php +++ b/src/Request.php @@ -211,7 +211,7 @@ public function setEncodingGzip() * If you want to request the URL with a (http|socks...) proxy (public or private). * * @param string $proxy [scheme]IP:PORT[:LOGIN:PASSWORD] - * Eg. : socks5://98.023.023.02:1098:cUrlRequestProxId:SecretPassword + * Eg. : socks5://98.023.023.02:1098:cUrlRequestProxId:SecretPassword * * @return self */ diff --git a/src/Response.php b/src/Response.php index 75301a1..13ca374 100644 --- a/src/Response.php +++ b/src/Response.php @@ -15,7 +15,7 @@ class Response /** @var array * */ private $info; - public function get($handle, string $url, int $returnHeader, bool $gzip) + public static function get($handle, string $url, int $returnHeader, bool $gzip) { $content = curl_exec($handle); diff --git a/tests/RequestTest.php b/tests/RequestTest.php index 587782c..0580145 100644 --- a/tests/RequestTest.php +++ b/tests/RequestTest.php @@ -11,7 +11,7 @@ class RequestTest extends \PHPUnit\Framework\TestCase public function testNotDownload() { - $url = 'https://www.google.fr/images/branding/googlelogo/1x/googlelogo_color_272x92dp.png';//'https://piedweb.com/assets/img/xl/bg.jpg'; + $url = 'https://piedweb.com/assets/img/xl/bg.jpg'; $request = new Request($url); $request ->setDefaultGetOptions()