mirror of
https://github.com/php-curl-class/php-curl-class.git
synced 2026-08-31 12:43:14 +00:00
Fix #404: Allow calling Curl::getInfo() without option
This commit is contained in:
@@ -201,7 +201,7 @@ Curl::error($callback)
|
||||
Curl::exec($ch = null)
|
||||
Curl::get($url, $data = array())
|
||||
Curl::getCookie($key)
|
||||
Curl::getInfo($opt)
|
||||
Curl::getInfo($opt = null)
|
||||
Curl::getOpt($option)
|
||||
Curl::getResponseCookie($key)
|
||||
Curl::head($url, $data = array())
|
||||
|
||||
+9
-2
@@ -422,9 +422,16 @@ class Curl
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function getInfo($opt)
|
||||
public function getInfo($opt = null)
|
||||
{
|
||||
return curl_getinfo($this->curl, $opt);
|
||||
$args = array();
|
||||
$args[] = $this->curl;
|
||||
|
||||
if (func_num_args()) {
|
||||
$args[] = $opt;
|
||||
}
|
||||
|
||||
return call_user_func_array('curl_getinfo', $args);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -3000,4 +3000,45 @@ class CurlTest extends PHPUnit_Framework_TestCase
|
||||
$curl->get(Test::TEST_URL, $data);
|
||||
$this->assertEquals('', $curl->response);
|
||||
}
|
||||
|
||||
public function testGetInfo()
|
||||
{
|
||||
$test = new Test();
|
||||
$test->server('server', 'GET');
|
||||
$info = $test->curl->getInfo();
|
||||
|
||||
$expected_keys = array(
|
||||
'url',
|
||||
'content_type',
|
||||
'http_code',
|
||||
'header_size',
|
||||
'request_size',
|
||||
'filetime',
|
||||
'ssl_verify_result',
|
||||
'redirect_count',
|
||||
'total_time',
|
||||
'namelookup_time',
|
||||
'connect_time',
|
||||
'pretransfer_time',
|
||||
'size_upload',
|
||||
'size_download',
|
||||
'speed_download',
|
||||
'speed_upload',
|
||||
'download_content_length',
|
||||
'upload_content_length',
|
||||
'starttransfer_time',
|
||||
'redirect_time',
|
||||
'certinfo',
|
||||
'primary_ip',
|
||||
'primary_port',
|
||||
'local_ip',
|
||||
'local_port',
|
||||
'redirect_url',
|
||||
'request_header',
|
||||
);
|
||||
|
||||
foreach ($expected_keys as $key) {
|
||||
$this->assertArrayHasKey($key, $info);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user