]> source.dussan.org Git - nextcloud-server.git/commitdiff
drop any fallback code related to curl - refs https://github.com/owncloud/core/pull...
authorThomas Müller <thomas.mueller@tmit.eu>
Thu, 12 Mar 2015 20:43:41 +0000 (21:43 +0100)
committerThomas Müller <thomas.mueller@tmit.eu>
Thu, 12 Mar 2015 20:43:41 +0000 (21:43 +0100)
apps/files_external/lib/amazons3.php
apps/files_external/lib/dropbox.php
apps/files_external/lib/google.php
apps/files_external/lib/swift.php
lib/private/files/storage/dav.php
lib/private/httphelper.php
lib/private/largefilehelper.php
lib/private/setup.php
tests/lib/httphelper.php

index 4d94e3561f8625c864c80a72f5c50a40e21affac..73345d3089368671f983142a9bf800e241b3f30f 100644 (file)
@@ -627,11 +627,7 @@ class AmazonS3 extends \OC\Files\Storage\Common {
         * check if curl is installed
         */
        public static function checkDependencies() {
-               if (function_exists('curl_init')) {
-                       return true;
-               } else {
-                       return array('curl');
-               }
+               return true;
        }
 
 }
index cc1e628f8516bf36799a7acbdf7cb95be456e3a5..3dea8515b7be7d0ff2f1f1fbf1f61d1b93fd1058 100644 (file)
@@ -316,11 +316,7 @@ class Dropbox extends \OC\Files\Storage\Common {
         * check if curl is installed
         */
        public static function checkDependencies() {
-               if (function_exists('curl_init')) {
-                       return true;
-               } else {
-                       return array('curl');
-               }
+               return true;
        }
 
 }
index bd9bdce2a671da248f8b7a808dcf7aa94cd8b036..92351bc08868761d23fa34e90527dd246cad68d1 100644 (file)
@@ -617,11 +617,7 @@ class Google extends \OC\Files\Storage\Common {
         * check if curl is installed
         */
        public static function checkDependencies() {
-               if (function_exists('curl_init')) {
-                       return true;
-               } else {
-                       return array('curl');
-               }
+               return true;
        }
 
 }
index 79effc048743dd8aa39d1a60762fd526e1222b86..37f81313701ff6ad03a77a485f99f8121ad4f5c1 100644 (file)
@@ -567,11 +567,7 @@ class Swift extends \OC\Files\Storage\Common {
         * check if curl is installed
         */
        public static function checkDependencies() {
-               if (function_exists('curl_init')) {
-                       return true;
-               } else {
-                       return array('curl');
-               }
+               return true;
        }
 
 }
index 7ca182621153c4d6008be51ac99bd130e4166fa4..e0f24e0532d69ca232f686dbeee29c2c0c7bbea5 100644 (file)
@@ -512,11 +512,7 @@ class DAV extends \OC\Files\Storage\Common {
         * check if curl is installed
         */
        public static function checkDependencies() {
-               if (function_exists('curl_init')) {
-                       return true;
-               } else {
-                       return array('curl');
-               }
+               return true;
        }
 
        /** {@inheritdoc} */
index 08c35e4ae08f51b15b397d152773a5d215cf9189..6bb8e1d3ec072e06bf1a48726a5b18be2ec74789 100644 (file)
@@ -60,82 +60,68 @@ class HTTPHelper {
 
                $proxy = $this->config->getSystemValue('proxy', null);
                $proxyUserPwd = $this->config->getSystemValue('proxyuserpwd', null);
-               if (function_exists('curl_init')) {
-                       $curl = curl_init();
-                       $max_redirects = 10;
-
-                       curl_setopt($curl, CURLOPT_HEADER, 0);
-                       curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
-                       curl_setopt($curl, CURLOPT_CONNECTTIMEOUT, 10);
-                       curl_setopt($curl, CURLOPT_URL, $url);
-                       curl_setopt($curl, CURLOPT_PROTOCOLS,  CURLPROTO_HTTP | CURLPROTO_HTTPS);
-                       curl_setopt($curl, CURLOPT_REDIR_PROTOCOLS,  CURLPROTO_HTTP | CURLPROTO_HTTPS);
-
-                       curl_setopt($curl, CURLOPT_USERAGENT, self::USER_AGENT);
-                       if ($proxy !== null) {
-                               curl_setopt($curl, CURLOPT_PROXY, $proxy);
-                       }
-                       if ($proxyUserPwd !== null) {
-                               curl_setopt($curl, CURLOPT_PROXYUSERPWD, $proxyUserPwd);
-                       }
+               $curl = curl_init();
+               $max_redirects = 10;
+
+               curl_setopt($curl, CURLOPT_HEADER, 0);
+               curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
+               curl_setopt($curl, CURLOPT_CONNECTTIMEOUT, 10);
+               curl_setopt($curl, CURLOPT_URL, $url);
+               curl_setopt($curl, CURLOPT_PROTOCOLS,  CURLPROTO_HTTP | CURLPROTO_HTTPS);
+               curl_setopt($curl, CURLOPT_REDIR_PROTOCOLS,  CURLPROTO_HTTP | CURLPROTO_HTTPS);
+
+               curl_setopt($curl, CURLOPT_USERAGENT, self::USER_AGENT);
+               if ($proxy !== null) {
+                       curl_setopt($curl, CURLOPT_PROXY, $proxy);
+               }
+               if ($proxyUserPwd !== null) {
+                       curl_setopt($curl, CURLOPT_PROXYUSERPWD, $proxyUserPwd);
+               }
 
-                       if (ini_get('open_basedir') === '') {
-                               curl_setopt($curl, CURLOPT_FOLLOWLOCATION, true);
-                               curl_setopt($curl, CURLOPT_MAXREDIRS, $max_redirects);
-                               $data = curl_exec($curl);
-                       } else {
-                               curl_setopt($curl, CURLOPT_FOLLOWLOCATION, false);
-                               $mr = $max_redirects;
-                               if ($mr > 0) {
-                                       $newURL = curl_getinfo($curl, CURLINFO_EFFECTIVE_URL);
-                                       $rcurl = curl_copy_handle($curl);
-                                       curl_setopt($rcurl, CURLOPT_HEADER, true);
-                                       curl_setopt($rcurl, CURLOPT_NOBODY, true);
-                                       curl_setopt($rcurl, CURLOPT_FORBID_REUSE, false);
-                                       curl_setopt($rcurl, CURLOPT_RETURNTRANSFER, true);
-                                       curl_setopt($rcurl, CURLOPT_USERAGENT, self::USER_AGENT);
-                                       do {
-                                               curl_setopt($rcurl, CURLOPT_URL, $newURL);
-                                               $header = curl_exec($rcurl);
-                                               if (curl_errno($rcurl)) {
-                                                       $code = 0;
+               if (ini_get('open_basedir') === '') {
+                       curl_setopt($curl, CURLOPT_FOLLOWLOCATION, true);
+                       curl_setopt($curl, CURLOPT_MAXREDIRS, $max_redirects);
+                       $data = curl_exec($curl);
+               } else {
+                       curl_setopt($curl, CURLOPT_FOLLOWLOCATION, false);
+                       $mr = $max_redirects;
+                       if ($mr > 0) {
+                               $newURL = curl_getinfo($curl, CURLINFO_EFFECTIVE_URL);
+                               $rCurl = curl_copy_handle($curl);
+                               curl_setopt($rCurl, CURLOPT_HEADER, true);
+                               curl_setopt($rCurl, CURLOPT_NOBODY, true);
+                               curl_setopt($rCurl, CURLOPT_FORBID_REUSE, false);
+                               curl_setopt($rCurl, CURLOPT_RETURNTRANSFER, true);
+                               curl_setopt($rCurl, CURLOPT_USERAGENT, self::USER_AGENT);
+                               do {
+                                       curl_setopt($rCurl, CURLOPT_URL, $newURL);
+                                       $header = curl_exec($rCurl);
+                                       if (curl_errno($rCurl)) {
+                                               $code = 0;
+                                       } else {
+                                               $code = curl_getinfo($rCurl, CURLINFO_HTTP_CODE);
+                                               if ($code == 301 || $code == 302) {
+                                                       preg_match('/Location:(.*?)\n/', $header, $matches);
+                                                       $newURL = trim(array_pop($matches));
                                                } else {
-                                                       $code = curl_getinfo($rcurl, CURLINFO_HTTP_CODE);
-                                                       if ($code == 301 || $code == 302) {
-                                                               preg_match('/Location:(.*?)\n/', $header, $matches);
-                                                               $newURL = trim(array_pop($matches));
-                                                       } else {
-                                                               $code = 0;
-                                                       }
+                                                       $code = 0;
                                                }
-                                       } while ($code && --$mr);
-                                       curl_close($rcurl);
-                                       if ($mr > 0) {
-                                               curl_setopt($curl, CURLOPT_URL, $newURL);
                                        }
-                               }
-
-                               if ($mr == 0 && $max_redirects > 0) {
-                                       $data = false;
-                               } else {
-                                       $data = curl_exec($curl);
+                               } while ($code && --$mr);
+                               curl_close($rCurl);
+                               if ($mr > 0) {
+                                       curl_setopt($curl, CURLOPT_URL, $newURL);
                                }
                        }
-                       curl_close($curl);
-               } else {
-                       $url = $this->getFinalLocationOfURL($url);
-                       $contextArray = $this->getDefaultContextArray();
 
-                       if ($proxy !== null) {
-                               $contextArray['http']['proxy'] = $proxy;
+                       if ($mr == 0 && $max_redirects > 0) {
+                               $data = false;
+                       } else {
+                               $data = curl_exec($curl);
                        }
-
-                       $ctx = stream_context_create(
-                               $contextArray
-                       );
-                       $data = @file_get_contents($url, 0, $ctx);
-
                }
+               curl_close($curl);
+
                return $data;
        }
 
@@ -158,29 +144,6 @@ class HTTPHelper {
                return stripos($url, 'https://') === 0 || stripos($url, 'http://') === 0;
        }
 
-       /**
-        * Returns the last HTTP or HTTPS site the request has been redirected too using the Location HTTP header
-        * This is a very ugly workaround about the missing functionality to restrict fopen() to protocols
-        * @param string $location Needs to be a HTTPS or HTTP URL
-        * @throws \Exception In case the initial URL is not a HTTP or HTTPS one
-        * @return string
-        */
-       public function getFinalLocationOfURL($location) {
-               if(!$this->isHTTPURL($location)) {
-                       throw new \Exception('URL must begin with HTTPS or HTTP.');
-               }
-               $headerArray = $this->getHeaders($location, 1);
-
-               if($headerArray !== false && isset($headerArray['Location'])) {
-                       while($this->isHTTPURL($headerArray['Location'])) {
-                               $location = $headerArray['Location'];
-                               $headerArray = $this->getHeaders($location);
-                       }
-               }
-
-               return $location;
-       }
-
        /**
         * create string of parameters for post request
         *
index b6a8c536e9bbf000e2e752c93122a52292f83df7..a5a8f302eaba8fc322d813c3ccc7bc9f16fcef32 100644 (file)
@@ -94,15 +94,15 @@ class LargeFileHelper {
        /**
        * @brief Tries to get the size of a file via a CURL HEAD request.
        *
-       * @param string $filename Path to the file.
+       * @param string $fileName Path to the file.
        *
        * @return null|int|float Number of bytes as number (float or int) or
        *                        null on failure.
        */
-       public function getFileSizeViaCurl($filename) {
-               if (function_exists('curl_init') && \OC::$server->getIniWrapper()->getString('open_basedir') === '') {
-                       $fencoded = rawurlencode($filename);
-                       $ch = curl_init("file://$fencoded");
+       public function getFileSizeViaCurl($fileName) {
+               if (\OC::$server->getIniWrapper()->getString('open_basedir') === '') {
+                       $encodedFileName = rawurlencode($fileName);
+                       $ch = curl_init("file://$encodedFileName");
                        curl_setopt($ch, CURLOPT_NOBODY, true);
                        curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
                        curl_setopt($ch, CURLOPT_HEADER, true);
@@ -129,8 +129,8 @@ class LargeFileHelper {
        */
        public function getFileSizeViaCOM($filename) {
                if (class_exists('COM')) {
-                       $fsobj = new \COM("Scripting.FileSystemObject");
-                       $file = $fsobj->GetFile($filename);
+                       $fsObj = new \COM("Scripting.FileSystemObject");
+                       $file = $fsObj->GetFile($filename);
                        return 0 + $file->Size;
                }
                return null;
index 44b6ad56cb89a77645aa44fae2c97a1737b70d46..830a6176caffa3a8fce167b7df304678526817bb 100644 (file)
@@ -184,16 +184,6 @@ class Setup {
                                'hint' => $this->l10n->t('Please remove the open_basedir setting within your php.ini or switch to 64-bit PHP.')
                        );
                }
-               if(!function_exists('curl_init') && PHP_INT_SIZE === 4) {
-                       $errors[] = array(
-                               'error' => $this->l10n->t(
-                                       'It seems that this %s instance is running on a 32-bit PHP environment and cURL is not installed. ' .
-                                       'This will lead to problems with files over 4 GB and is highly discouraged.',
-                                       $this->defaults->getName()
-                               ),
-                               'hint' => $this->l10n->t('Please install the cURL extension and restart your webserver.')
-                       );
-               }
 
                return array(
                        'hasSQLite' => isset($databases['sqlite']),
index 48d6543f1f208b59bacb3ae729e42dad2c4bab6e..fe76f984258ebcda9f6e9b5d4dcf97f5c1a7b18c 100644 (file)
@@ -40,49 +40,6 @@ class TestHTTPHelper extends \Test\TestCase {
                );
        }
 
-       /**
-        * Note: Not using a dataprovider because onConsecutiveCalls expects not
-        * an array but the function arguments directly
-        */
-       public function testGetFinalLocationOfURLValid() {
-               $url = 'https://www.owncloud.org/enterprise/';
-               $expected = 'https://www.owncloud.com/enterprise/';
-               $this->httpHelperMock->expects($this->any())
-                       ->method('getHeaders')
-                       ->will($this->onConsecutiveCalls(
-                               array('Location' => 'http://www.owncloud.com/enterprise/'),
-                               array('Location' => 'https://www.owncloud.com/enterprise/')
-                       ));
-               $result = $this->httpHelperMock->getFinalLocationOfURL($url);
-               $this->assertSame($expected, $result);
-       }
-
-       /**
-        * Note: Not using a dataprovider because onConsecutiveCalls expects not
-        * an array but the function arguments directly
-        */
-       public function testGetFinalLocationOfURLInvalid() {
-               $url = 'https://www.owncloud.org/enterprise/';
-               $expected = 'http://www.owncloud.com/enterprise/';
-               $this->httpHelperMock->expects($this->any())
-                       ->method('getHeaders')
-                       ->will($this->onConsecutiveCalls(
-                               array('Location' => 'http://www.owncloud.com/enterprise/'),
-                               array('Location' => 'file://etc/passwd'),
-                               array('Location' => 'http://www.example.com/')
-                       ));
-               $result = $this->httpHelperMock->getFinalLocationOfURL($url);
-               $this->assertSame($expected, $result);
-       }
-
-       /**
-        * @expectedException \Exception
-        * @expectedExceptionMessage URL must begin with HTTPS or HTTP.
-        */
-       public function testGetFinalLocationOfURLException() {
-               $this->httpHelperMock->getFinalLocationOfURL('file://etc/passwd');
-       }
-
        /**
         * @dataProvider isHttpTestData
         */
@@ -90,11 +47,10 @@ class TestHTTPHelper extends \Test\TestCase {
                        $this->assertSame($expected, $this->httpHelperMock->isHTTPURL($url));
        }
 
-
        /**
         * @dataProvider postParameters
         */
-       public function testassemblePostParameters($parameterList, $expectedResult) {
+       public function testAssemblePostParameters($parameterList, $expectedResult) {
                $helper = \OC::$server->getHTTPHelper();
                $result = \Test_Helper::invokePrivate($helper, 'assemblePostParameters', array($parameterList));
                $this->assertSame($expectedResult, $result);
@@ -107,6 +63,4 @@ class TestHTTPHelper extends \Test\TestCase {
                        array(array(), ''),
                );
        }
-
-
 }