Annotation of embedaddon/php/ext/curl/tests/curl_write_callback.phpt, revision 1.1.1.1

1.1       misho       1: --TEST--
                      2: Test curl option CURLOPT_WRITEFUNCTION
                      3: --CREDITS--
                      4: Mathieu Kooiman <mathieuk@gmail.com>
                      5: Dutch UG, TestFest 2009, Utrecht
                      6: --DESCRIPTION--
                      7: 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.
                      8: --SKIPIF--
                      9: <?php if (!extension_loaded("curl")) print "skip"; ?>
                     10: --FILE--
                     11: <?php
                     12: 
                     13: function curl_callback($curl_handle, $received_data)
                     14: {
                     15:        echo $received_data;
                     16:        return strlen($received_data);
                     17: }
                     18: 
                     19: $log_file = tempnam(sys_get_temp_dir(), 'php-curl-test');
                     20: 
                     21: $fp = fopen($log_file, 'w+');
                     22: fwrite($fp, "test");
                     23: fclose($fp);
                     24: 
                     25: $ch = curl_init();
                     26: curl_setopt($ch, CURLOPT_WRITEFUNCTION, 'curl_callback');
                     27: curl_setopt($ch, CURLOPT_URL, 'file://' . $log_file);
                     28: curl_exec($ch);
                     29: curl_close($ch);
                     30: 
                     31: // cleanup
                     32: unlink($log_file);
                     33: 
                     34: ?>
                     35: --EXPECT--
                     36: test

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>