Annotation of embedaddon/php/ext/curl/tests/curl_setopt_basic002.phpt, revision 1.1.1.1
1.1 misho 1: --TEST--
2: curl_setopt basic tests with CURLOPT_STDERR.
3: --CREDITS--
4: Paul Sohier
5: #phptestfest utrecht
6: --SKIPIF--
7: <?php if (!extension_loaded("curl") || false === getenv('PHP_CURL_HTTP_REMOTE_SERVER')) print "skip need PHP_CURL_HTTP_REMOTE_SERVER environment variable"; ?>
8: --FILE--
9: <?php
10:
11: $host = getenv('PHP_CURL_HTTP_REMOTE_SERVER');
12:
13: // start testing
14: echo "*** Testing curl_setopt with CURLOPT_STDERR\n";
15:
16: $temp_file = tempnam(sys_get_temp_dir(), 'CURL_STDERR');
17:
18: $handle = fopen($temp_file, 'w');
19:
20: $url = "{$host}/";
21: $ch = curl_init();
22:
23: curl_setopt($ch, CURLOPT_VERBOSE, 1);
24: curl_setopt($ch, CURLOPT_STDERR, $handle);
25: $curl_content = curl_exec($ch);
26:
27: fclose($handle);
28: unset($handle);
29: var_dump(preg_replace('/[\r\n]/', ' ', file_get_contents($temp_file)));
30: @unlink($temp_file);
31:
32: ob_start(); // start output buffering
33: $handle = fopen($temp_file, 'w');
34: curl_setopt($ch, CURLOPT_URL, $url); //set the url we want to use
35: curl_setopt($ch, CURLOPT_STDERR, $handle);
36: $data = curl_exec($ch);
37: ob_end_clean();
38:
39: fclose($handle);
40: unset($handle);
41: var_dump(preg_replace('/[\r\n]/', ' ', file_get_contents($temp_file)));
42: @unlink($temp_file);
43:
44: curl_close($ch);
45:
46: ?>
47: --EXPECTF--
48: *** Testing curl_setopt with CURLOPT_STDERR
49: string(%d) "%S"
50: string(%d) "%S"
51: * Closing connection #%d
52:
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>