<?php
/*
+--------------------------------------------------------------------+
- | CiviCRM version 4.4 |
+ | CiviCRM version 4.5 |
+--------------------------------------------------------------------+
- | Copyright CiviCRM LLC (c) 2004-2013 |
+ | Copyright CiviCRM LLC (c) 2004-2014 |
+--------------------------------------------------------------------+
| This file is a part of CiviCRM. |
| |
* want to deal with that so late in the 4.3 dev cycle.
*
* @package CRM
- * @copyright CiviCRM LLC (c) 2004-2013
+ * @copyright CiviCRM LLC (c) 2004-2014
* $Id$
*
*/
*/
protected $connectionTimeout;
+ /**
+ * @return CRM_Utils_HttpClient
+ */
public static function singleton() {
if (!self::$singleton) {
self::$singleton = new CRM_Utils_HttpClient();
return self::$singleton;
}
+ /**
+ * @param null $connectionTimeout
+ */
public function __construct($connectionTimeout = NULL) {
$this->connectionTimeout = $connectionTimeout;
}
* Send an HTTP POST for a remote resource
*
* @param string $remoteFile URL of a .zip file
- * @param string $localFile path at which to store the .zip file
+ * @param $params
+ *
+ * @internal param string $localFile path at which to store the .zip file
* @return array array(0 => STATUS_OK|STATUS_DL_ERROR, 1 => string)
*/
public function post($remoteFile, $params) {
curl_setopt($ch, CURLOPT_HEADER, FALSE);
curl_setopt($ch, CURLOPT_ENCODING, 'gzip');
curl_setopt($ch, CURLOPT_VERBOSE, 0);
- curl_setopt($ch, CURLOPT_FOLLOWLOCATION, TRUE);
+ if ($this->isRedirectSupported()) {
+ curl_setopt($ch, CURLOPT_FOLLOWLOCATION, TRUE);
+ }
if ($this->connectionTimeout !== NULL) {
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $this->connectionTimeout);
}
return array($ch, $caConfig);
}
+ /**
+ * @return bool
+ */
+ public function isRedirectSupported() {
+ return (ini_get('open_basedir') == '') && (ini_get('safe_mode') == 'Off' || ini_get('safe_mode') == '' || ini_get('safe_mode') === FALSE);
+ }
+
}