Add Curl::getInfo()

This commit is contained in:
Zach Borboa
2016-07-11 01:07:35 -07:00
parent 978f149d56
commit 1028030d8f
2 changed files with 17 additions and 4 deletions
+2
View File
@@ -193,6 +193,7 @@ $multi_curl->start(); // Blocks until all items in the queue have been processed
```php
Curl::__construct($base_url = null)
Curl::__destruct()
Curl::__get($name)
Curl::beforeSend($callback)
Curl::buildPostData($data)
Curl::call()
@@ -205,6 +206,7 @@ Curl::error($callback)
Curl::exec($ch = null)
Curl::get($url, $data = array())
Curl::getCookie($key)
Curl::getInfo($opt)
Curl::getOpt($option)
Curl::getResponseCookie($key)
Curl::getResponseCookies()
+15 -4
View File
@@ -350,7 +350,7 @@ class Curl
}
$this->curlErrorMessage = curl_error($this->curl);
$this->curlError = !($this->curlErrorCode === 0);
$this->httpStatusCode = curl_getinfo($this->curl, CURLINFO_HTTP_CODE);
$this->httpStatusCode = $this->getInfo(CURLINFO_HTTP_CODE);
$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;
@@ -358,7 +358,7 @@ class Curl
// NOTE: CURLINFO_HEADER_OUT set to true is required for requestHeaders
// to not be empty (e.g. $curl->setOpt(CURLINFO_HEADER_OUT, true);).
if ($this->getOpt(CURLINFO_HEADER_OUT) === true) {
$this->requestHeaders = $this->parseRequestHeaders(curl_getinfo($this->curl, CURLINFO_HEADER_OUT));
$this->requestHeaders = $this->parseRequestHeaders($this->getInfo(CURLINFO_HEADER_OUT));
}
$this->responseHeaders = $this->parseResponseHeaders($this->rawResponseHeaders);
$this->response = $this->parseResponse($this->responseHeaders, $this->rawResponse);
@@ -403,6 +403,17 @@ class Curl
return $this->exec();
}
/**
* Get Info
*
* @access public
* @param $opt
*/
public function getInfo($opt)
{
return curl_getinfo($this->curl, $opt);
}
/**
* Get Opt
*
@@ -969,7 +980,7 @@ class Curl
* @access private
*/
private function __get_effectiveUrl() {
return curl_getinfo($this->curl, CURLINFO_EFFECTIVE_URL);
return $this->getInfo(CURLINFO_EFFECTIVE_URL);
}
/**
@@ -978,7 +989,7 @@ class Curl
* @access private
*/
private function __get_totalTime() {
return curl_getinfo($this->curl, CURLINFO_TOTAL_TIME);
return $this->getInfo(CURLINFO_TOTAL_TIME);
}
/**