Index: branches/5.2.x/core/units/helpers/curl_helper.php =================================================================== diff -u -N -r15337 -r15426 --- branches/5.2.x/core/units/helpers/curl_helper.php (.../curl_helper.php) (revision 15337) +++ branches/5.2.x/core/units/helpers/curl_helper.php (.../curl_helper.php) (revision 15426) @@ -1,6 +1,6 @@ responseHeaders = Array (); $this->prepareOptions(); - $this->lastResponse = $this->execFollow(); + $this->lastResponse = $this->_sendRequest(); $this->Finalize($close_connection); return $this->lastResponse; } /** - * Fixes curl inability to automatically follow location when safe_mode/open_basedir restriction in effect + * Reads data from remote url * - * @param bool $headers_only * @return string * @access protected */ - protected function execFollow($headers_only = false) + protected function _sendRequest() { - curl_setopt($this->connectionID, CURLOPT_HEADER, true); curl_setopt($this->connectionID, CURLOPT_RETURNTRANSFER, true); - if ( $this->followLocation && !$this->followLocationLimited() ) { - // no restrictions - let curl do automatic redirects - curl_setopt($this->connectionID, CURLOPT_FOLLOWLOCATION, true); + if ( $this->followLocation ) { + if ( $this->followLocationLimited() ) { + return $this->_followLocationManually(); + } + else { + // no restrictions - let curl do automatic redirects + curl_setopt($this->connectionID, CURLOPT_FOLLOWLOCATION, true); + } } + return curl_exec($this->connectionID); + } + + /** + * Fixes curl inability to automatically follow location when safe_mode/open_basedir restriction in effect + * + * @return string + * @access protected + */ + protected function _followLocationManually() + { + curl_setopt($this->connectionID, CURLOPT_HEADER, true); $data = curl_exec($this->connectionID); + $http_code = $this->getInfo(CURLINFO_HTTP_CODE); if ( $http_code == 301 || $http_code == 302 ) { @@ -416,14 +432,10 @@ curl_setopt($this->connectionID, CURLOPT_URL, $url); $this->lastRedirectCount++; - return $this->execFollow($headers_only); + return $this->_followLocationManually(); } } - if ( $headers_only ) { - return $data; - } - list(, $body) = explode("\r\n\r\n", $data, 2); return $body;