Browse Source

Add GET parameters do file download

Jan Oris 4 years ago
parent
commit
58fc74c92f
3 changed files with 16 additions and 8 deletions
  1. 10 2
      CHANGELOG.md
  2. 2 2
      composer.json
  3. 4 4
      src/Builder.php

+ 10 - 2
CHANGELOG.md

@@ -2,9 +2,17 @@
 
 All Notable changes to `ixudra/curl` will be documented in this file
 
-## 6.18.0 - 2019-11-01
+## 6.20.0 - 2020-08-07
+### Fixed
+- Data is now passed as POST parameters instead of GET for `DELETE` REQUESTS
+
+### Added
+- Additional docblocks
+- GET parameters are added to the URL on file download
+
+## 6.19.0 - 2020-03-03
 ### Added
-- Added key-value support to `withHeaders()` method
+- Added `withConnectTimeout()` method
 
 ## 6.17.0 - 2019-09-13
 ### Added

+ 2 - 2
composer.json

@@ -1,7 +1,7 @@
 {
     "name": "ixudra/curl",
-    "description": "Custom PHP Curl library for the Laravel 5 framework - developed by Ixudra",
-    "version": "6.19.0",
+    "description": "Custom PHP Curl library for the Laravel framework - developed by Ixudra",
+    "version": "6.20.0",
     "keywords": ["Ixudra", "Laravel", "Curl"],
     "homepage": "http://ixudra.be",
     "license": "MIT",

+ 4 - 4
src/Builder.php

@@ -399,6 +399,7 @@ class Builder {
       */
      public function download($fileName)
      {
+         $this->appendDataToURL();
          $this->packageOptions[ 'saveFile' ] = $fileName;
 
          return $this->send();
@@ -419,7 +420,7 @@ class Builder {
         }
 
         if( $this->packageOptions[ 'asJsonRequest' ] ) {
-            $parameters = json_encode($parameters);
+            $parameters = \json_encode($parameters);
         }
 
         $this->curlOptions[ 'POSTFIELDS' ] = $parameters;
@@ -474,7 +475,6 @@ class Builder {
      */
     public function delete()
     {
-        // $this->appendDataToURL();
         $this->setPostParameters();
 
         return $this->withOption('CUSTOMREQUEST', 'DELETE')
@@ -557,7 +557,7 @@ class Builder {
             }
         }, array_filter(array_map('trim', explode("\r\n", $headerString)))));
 
-        $results = [];
+        $results = array();
 
         foreach( $headers as $values ) {
             if( !is_array($values) ) {
@@ -627,7 +627,7 @@ class Builder {
         foreach( $this->curlOptions as $key => $value ) {
             $arrayKey = constant( 'CURLOPT_' . $key );
 
-            if( !$this->packageOptions[ 'containsFile' ] && $key == 'POSTFIELDS' && is_array( $value ) ) {
+            if( !$this->packageOptions[ 'containsFile' ] && $key === 'POSTFIELDS' && is_array( $value ) ) {
                 $results[ $arrayKey ] = http_build_query( $value, null, '&' );
             } else {
                 $results[ $arrayKey ] = $value;