Annotation of embedaddon/php/ext/curl/tests/curl_multi_getcontent_basic3.phpt, revision 1.1
1.1 ! misho 1: --TEST--
! 2: Curl_multi_getcontent() basic test with different sources (local file/http)
! 3: --CREDITS--
! 4: Rein Velt (rein@velt.org)
! 5: #TestFest Utrecht 20090509
! 6: --SKIPIF--
! 7: <?php
! 8: if (!extension_loaded('curl')) print 'skip need ext/curl';
! 9: if (false === getenv('PHP_CURL_HTTP_REMOTE_SERVER')) {
! 10: exit("skip PHP_CURL_HTTP_REMOTE_SERVER env variable is not defined");
! 11: }
! 12: ?>
! 13: --FILE--
! 14: <?php
! 15: //CURL_MULTI_GETCONTENT TEST
! 16:
! 17: //CREATE RESOURCES
! 18: $ch1=curl_init();
! 19: $ch2=curl_init();
! 20:
! 21: //SET URL AND OTHER OPTIONS
! 22: $host = getenv('PHP_CURL_HTTP_REMOTE_SERVER');
! 23: curl_setopt($ch1, CURLOPT_URL, "{$host}/get.php?test=getpost&get_param=Hello%20World");
! 24: curl_setopt($ch2, CURLOPT_URL, "file://".dirname(__FILE__). DIRECTORY_SEPARATOR . "curl_testdata2.txt");
! 25: curl_setopt($ch1, CURLOPT_RETURNTRANSFER, true);
! 26: curl_setopt($ch2, CURLOPT_RETURNTRANSFER, true);
! 27:
! 28: //CREATE MULTIPLE CURL HANDLE
! 29: $mh=curl_multi_init();
! 30:
! 31: //ADD THE 2 HANDLES
! 32: curl_multi_add_handle($mh,$ch1);
! 33: curl_multi_add_handle($mh,$ch2);
! 34:
! 35: //EXECUTE
! 36: $running=0;
! 37: do {
! 38: curl_multi_exec($mh,$running);
! 39: } while ($running>0);
! 40:
! 41: $results1=curl_multi_getcontent($ch1);
! 42: $results2=curl_multi_getcontent($ch2);
! 43:
! 44: //CLOSE
! 45: curl_multi_remove_handle($mh,$ch1);
! 46: curl_multi_remove_handle($mh,$ch2);
! 47: curl_multi_close($mh);
! 48:
! 49: echo $results1;
! 50: echo $results2;
! 51:
! 52: ?>
! 53: --EXPECTF--
! 54: array(2) {
! 55: ["test"]=>
! 56: string(7) "getpost"
! 57: ["get_param"]=>
! 58: string(11) "Hello World"
! 59: }
! 60: array(0) {
! 61: }
! 62: CURL2
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>