Make Curl::effectiveUrl a deferred property

This commit is contained in:
Zach Borboa
2016-07-11 00:49:15 -07:00
parent b24b575e58
commit 978f149d56
+15 -2
View File
@@ -58,7 +58,6 @@ class Curl
public $baseUrl = null;
public $url = null;
public $effectiveUrl = null;
public $requestHeaders = null;
public $responseHeaders = null;
public $rawResponseHeaders = '';
@@ -82,6 +81,7 @@ class Curl
private $xmlPattern = '~^(?:text/|application/(?:atom\+|rss\+)?)xml~i';
private static $deferredProperties = array(
'effectiveUrl',
'totalTime',
);
@@ -354,7 +354,6 @@ class Curl
$this->httpError = in_array(floor($this->httpStatusCode / 100), array(4, 5));
$this->error = $this->curlError || $this->httpError;
$this->errorCode = $this->error ? ($this->curlError ? $this->curlErrorCode : $this->httpStatusCode) : 0;
$this->effectiveUrl = curl_getinfo($this->curl, CURLINFO_EFFECTIVE_URL);
// NOTE: CURLINFO_HEADER_OUT set to true is required for requestHeaders
// to not be empty (e.g. $curl->setOpt(CURLINFO_HEADER_OUT, true);).
@@ -964,6 +963,20 @@ class Curl
return $return;
}
/**
* Get Effective Url
*
* @access private
*/
private function __get_effectiveUrl() {
return curl_getinfo($this->curl, CURLINFO_EFFECTIVE_URL);
}
/**
* Get Total Time
*
* @access private
*/
private function __get_totalTime() {
return curl_getinfo($this->curl, CURLINFO_TOTAL_TIME);
}