diff options
| author | Ondřej Surý <ondrej@sury.org> | 2010-01-07 13:31:53 +0100 |
|---|---|---|
| committer | Ondřej Surý <ondrej@sury.org> | 2010-01-07 13:31:53 +0100 |
| commit | 0fab6db7cac8d2be99579dd049f812a8ff98e74f (patch) | |
| tree | 91f01b0d06916c78262404096bfd466b8e95e5b5 /ext/curl/tests/curl_write_callback.phpt | |
| parent | d3a8757891280dc6650ca7eead67830c794b0e7b (diff) | |
| download | php-upstream/5.3.1.tar.gz | |
Imported Upstream version 5.3.1upstream/5.3.1
Diffstat (limited to 'ext/curl/tests/curl_write_callback.phpt')
| -rw-r--r-- | ext/curl/tests/curl_write_callback.phpt | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/ext/curl/tests/curl_write_callback.phpt b/ext/curl/tests/curl_write_callback.phpt new file mode 100644 index 000000000..c0b733ee4 --- /dev/null +++ b/ext/curl/tests/curl_write_callback.phpt @@ -0,0 +1,36 @@ +--TEST-- +Test curl option CURLOPT_WRITEFUNCTION +--CREDITS-- +Mathieu Kooiman <mathieuk@gmail.com> +Dutch UG, TestFest 2009, Utrecht +--DESCRIPTION-- +Writes the value 'test' to a temporary file. Use curl to access this file, passing the output into a callback. Tests the PHP_CURL_USER case in curl_write. +--SKIPIF-- +<?php if (!extension_loaded("curl")) print "skip"; ?> +--FILE-- +<?php + +function curl_callback($curl_handle, $received_data) +{ + echo $received_data; + return strlen($received_data); +} + +$log_file = tempnam(sys_get_temp_dir(), 'php-curl-test'); + +$fp = fopen($log_file, 'w+'); +fwrite($fp, "test"); +fclose($fp); + +$ch = curl_init(); +curl_setopt($ch, CURLOPT_WRITEFUNCTION, 'curl_callback'); +curl_setopt($ch, CURLOPT_URL, 'file://' . $log_file); +curl_exec($ch); +curl_close($ch); + +// cleanup +unlink($log_file); + +?> +--EXPECT-- +test |
