Changeset View
Changeset View
Standalone View
Standalone View
core/units/helpers/curl_helper.php
Show First 20 Lines • Show All 142 Lines • ▼ Show 20 Line(s) | |||||
/** | /** | ||||
* Creates an instance of kCurlHelper class | * Creates an instance of kCurlHelper class | ||||
*/ | */ | ||||
public function __construct() | public function __construct() | ||||
{ | { | ||||
parent::__construct(); | parent::__construct(); | ||||
$this->debugMode = kUtil::constOn('DBG_CURL'); | $this->debugMode = kUtil::constOn('DBG_CURL'); | ||||
// Happens, when cURL binding version is below v7.18.2. | |||||
if ( !defined('CURLINFO_REDIRECT_URL') ) { | |||||
define('CURLINFO_REDIRECT_URL', 1048607); | |||||
} | |||||
} | } | ||||
/** | /** | ||||
* Reset connection settings (not results) after connection was closed | * Reset connection settings (not results) after connection was closed | ||||
* | * | ||||
* @access protected | * @access protected | ||||
*/ | */ | ||||
protected function _resetSettings() | protected function _resetSettings() | ||||
▲ Show 20 Lines • Show All 330 Lines • ▼ Show 20 Line(s) | |||||
* @access public | * @access public | ||||
*/ | */ | ||||
public function getInfo($info_type) | public function getInfo($info_type) | ||||
{ | { | ||||
if ( $info_type == CURLINFO_REDIRECT_COUNT && $this->followLocationLimited() ) { | if ( $info_type == CURLINFO_REDIRECT_COUNT && $this->followLocationLimited() ) { | ||||
return $this->lastRedirectCount; | return $this->lastRedirectCount; | ||||
} | } | ||||
if ( $info_type == CURLINFO_REDIRECT_URL ) { | |||||
if ( $this->followLocation ) { | |||||
return ''; | |||||
alex: # Please move this IF inside next IF.
# Update test plan to reflect regular usage of `getInfo`… | |||||
} | |||||
foreach ( $this->responseHeaders as $header ) { | |||||
if ( preg_match('/^location: (.*)$/i', $header, $matches) ) { | |||||
return $matches[1]; | |||||
Done ReplyWhen kCurlHelper::$followLocation is enabled we should immediately return an empty string. Doesn't work according to docs from http://php.net/manual/en/function.curl-getinfo.php page. alex: When `kCurlHelper::$followLocation` is enabled we should immediately return an empty string. | |||||
Done ReplyReturn the value, that curl_getinfo($ch, CURLINFO_REDIRECT_URL) returns in real life when no Location: header was found. Maybe it really returns false, but double check just in case. alex: Return the value, that `curl_getinfo($ch, CURLINFO_REDIRECT_URL)` returns in real life when no… | |||||
} | |||||
} | |||||
return ''; | |||||
} | |||||
return curl_getinfo($this->connectionID, $info_type); | return curl_getinfo($this->connectionID, $info_type); | ||||
} | } | ||||
/** | /** | ||||
* Detects, that follow location can't be done automatically by curl due safe_mode/open_basedir restrictions | * Detects, that follow location can't be done automatically by curl due safe_mode/open_basedir restrictions | ||||
* | * | ||||
* @return bool | * @return bool | ||||
* @access protected | * @access protected | ||||
▲ Show 20 Lines • Show All 60 Lines • ▼ Show 20 Line(s) | |||||
public function isGoodResponseCode() | public function isGoodResponseCode() | ||||
{ | { | ||||
if ( $this->lastErrorCode != 0 ) { | if ( $this->lastErrorCode != 0 ) { | ||||
return false; | return false; | ||||
} | } | ||||
return ($this->lastHTTPCode == 200) || ($this->lastHTTPCode >= 300 && $this->lastHTTPCode < 310); | return ($this->lastHTTPCode == 200) || ($this->lastHTTPCode >= 300 && $this->lastHTTPCode < 310); | ||||
} | } | ||||
} | } | ||||
Expected 0 spaces before closing brace; 4 found Lint: CodingStandard.Classes.ClassDeclaration.SpaceBeforeCloseBrace: Expected 0 spaces before closing brace; 4 found | |||||
No newline at end of file |
This causes a side effect, that regular class to getInfo method (not asking redirect url) would fail.