Browse Source

Merge branch 'master' into 3.next

Mark Story 6 years ago
parent
commit
5a3768be4c
3 changed files with 42 additions and 2 deletions
  1. 2 2
      .appveyor.yml
  2. 4 0
      src/Http/Client/Adapter/Curl.php
  3. 36 0
      tests/TestCase/Http/Client/Adapter/CurlTest.php

+ 2 - 2
.appveyor.yml

@@ -38,9 +38,9 @@ install:
   - echo extension=fileinfo >> php.ini
   - php -v
 
-  - curl -fsS https://windows.php.net/downloads/pecl/releases/pdo_sqlsrv/5.2.0/php_pdo_sqlsrv-5.2.0-7.2-nts-vc15-x64.zip -o pdosqlsrv.zip
+  - curl -fsS https://windows.php.net/downloads/pecl/releases/pdo_sqlsrv/5.6.1/php_pdo_sqlsrv-5.6.1-7.2-nts-vc15-x64.zip -o pdosqlsrv.zip
   - 7z x pdosqlsrv.zip -oC:\php\ext php_pdo_sqlsrv.dll -aoa > nul
-  - curl -fsS https://windows.php.net/downloads/pecl/releases/sqlsrv/5.2.0/php_sqlsrv-5.2.0-7.2-nts-vc15-x64.zip -o sqlsrv.zip
+  - curl -fsS https://windows.php.net/downloads/pecl/releases/sqlsrv/5.6.1/php_sqlsrv-5.6.1-7.2-nts-vc15-x64.zip -o sqlsrv.zip
   - 7z x sqlsrv.zip -oC:\php\ext php_sqlsrv.dll -aoa > nul
   - echo extension=pdo_sqlsrv >> php.ini
   - echo extension=sqlsrv >> php.ini

+ 4 - 0
src/Http/Client/Adapter/Curl.php

@@ -96,6 +96,10 @@ class Curl implements AdapterInterface
         if ($body) {
             $body->rewind();
             $out[CURLOPT_POSTFIELDS] = $body->getContents();
+            // GET requests with bodies require custom request to be used.
+            if (isset($out[CURLOPT_HTTPGET])) {
+                $out[CURLOPT_CUSTOMREQUEST] = 'get';
+            }
         }
 
         if (empty($options['ssl_cafile'])) {

+ 36 - 0
tests/TestCase/Http/Client/Adapter/CurlTest.php

@@ -119,6 +119,42 @@ class CurlTest extends TestCase
      *
      * @return void
      */
+    public function testBuildOptionsGetWithBody()
+    {
+        $options = [
+            'timeout' => 5,
+        ];
+        $request = new Request(
+            'http://localhost/things',
+            'GET',
+            ['Cookie' => 'testing=value'],
+            '{"some":"body"}'
+        );
+        $result = $this->curl->buildOptions($request, $options);
+        $expected = [
+            CURLOPT_URL => 'http://localhost/things',
+            CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
+            CURLOPT_RETURNTRANSFER => true,
+            CURLOPT_HEADER => true,
+            CURLOPT_HTTPHEADER => [
+                'Cookie: testing=value',
+                'Connection: close',
+                'User-Agent: CakePHP',
+            ],
+            CURLOPT_HTTPGET => true,
+            CURLOPT_POSTFIELDS => '{"some":"body"}',
+            CURLOPT_CUSTOMREQUEST => 'get',
+            CURLOPT_TIMEOUT => 5,
+            CURLOPT_CAINFO => $this->caFile,
+        ];
+        $this->assertSame($expected, $result);
+    }
+
+    /**
+     * Test converting client options into curl ones.
+     *
+     * @return void
+     */
     public function testBuildOptionsPost()
     {
         $options = [];