Browse Source

feat: add encoding option

Hugh Harlequin 2 years ago
parent
commit
855f104104
2 changed files with 14 additions and 1 deletions
  1. 2 1
      .gitignore
  2. 12 0
      src/Builder.php

+ 2 - 1
.gitignore

@@ -1,3 +1,4 @@
 /vendor
 composer.phar
-.DS_Store
+.DS_Store
+.idea

+ 12 - 0
src/Builder.php

@@ -22,6 +22,7 @@ class Builder {
         'SSL_VERIFYPEER'        => false,
         'NOBODY'                => false,
         'HEADER'                => false,
+        'ENCODING'              => '',
     );
 
     /** @var array $packageOptions      Array with options that are not specific to cURL but are used by the package */
@@ -52,6 +53,17 @@ class Builder {
         return $this->withCurlOption( 'URL', $url );
     }
 
+    /**
+     * Set the request return content encoding by
+     *
+     * @param   string $encode    The return string decode by (Default: gzip,deflate)
+     * @return Builder
+     */
+    public function withEncoding($encode = 'gzip,deflate')
+    {
+        return $this->withCurlOption( 'ENCODING', $encode );
+    }
+
     /**
      * Set the request timeout
      *