File tree Expand file tree Collapse file tree 3 files changed +51
-3
lines changed Expand file tree Collapse file tree 3 files changed +51
-3
lines changed Original file line number Diff line number Diff line change @@ -201,7 +201,7 @@ Curl::error($callback)
201201Curl::exec($ch = null)
202202Curl::get($url, $data = array())
203203Curl::getCookie($key)
204- Curl::getInfo($opt)
204+ Curl::getInfo($opt = null )
205205Curl::getOpt($option)
206206Curl::getResponseCookie($key)
207207Curl::head($url, $data = array())
Original file line number Diff line number Diff line change @@ -422,9 +422,16 @@ public function get($url, $data = array())
422422 *
423423 * @return mixed
424424 */
425- public function getInfo ($ opt )
425+ public function getInfo ($ opt = null )
426426 {
427- return curl_getinfo ($ this ->curl , $ opt );
427+ $ args = array ();
428+ $ args [] = $ this ->curl ;
429+
430+ if (func_num_args ()) {
431+ $ args [] = $ opt ;
432+ }
433+
434+ return call_user_func_array ('curl_getinfo ' , $ args );
428435 }
429436
430437 /**
Original file line number Diff line number Diff line change @@ -3000,4 +3000,45 @@ public function testUnsetHeader()
30003000 $ curl ->get (Test::TEST_URL , $ data );
30013001 $ this ->assertEquals ('' , $ curl ->response );
30023002 }
3003+
3004+ public function testGetInfo ()
3005+ {
3006+ $ test = new Test ();
3007+ $ test ->server ('server ' , 'GET ' );
3008+ $ info = $ test ->curl ->getInfo ();
3009+
3010+ $ expected_keys = array (
3011+ 'url ' ,
3012+ 'content_type ' ,
3013+ 'http_code ' ,
3014+ 'header_size ' ,
3015+ 'request_size ' ,
3016+ 'filetime ' ,
3017+ 'ssl_verify_result ' ,
3018+ 'redirect_count ' ,
3019+ 'total_time ' ,
3020+ 'namelookup_time ' ,
3021+ 'connect_time ' ,
3022+ 'pretransfer_time ' ,
3023+ 'size_upload ' ,
3024+ 'size_download ' ,
3025+ 'speed_download ' ,
3026+ 'speed_upload ' ,
3027+ 'download_content_length ' ,
3028+ 'upload_content_length ' ,
3029+ 'starttransfer_time ' ,
3030+ 'redirect_time ' ,
3031+ 'certinfo ' ,
3032+ 'primary_ip ' ,
3033+ 'primary_port ' ,
3034+ 'local_ip ' ,
3035+ 'local_port ' ,
3036+ 'redirect_url ' ,
3037+ 'request_header ' ,
3038+ );
3039+
3040+ foreach ($ expected_keys as $ key ) {
3041+ $ this ->assertArrayHasKey ($ key , $ info );
3042+ }
3043+ }
30033044}
You can’t perform that action at this time.
0 commit comments