curl_reset.phpt 833 B

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. --TEST--
  2. Test curl_reset
  3. --SKIPIF--
  4. <?php if (!extension_loaded("curl")) print "skip";
  5. if (!function_exists("curl_reset")) exit("skip curl_reset doesn't exists (require libcurl >= 7.12.1)");
  6. ?>
  7. --FILE--
  8. <?php
  9. $test_file = tempnam(sys_get_temp_dir(), 'php-curl-test');
  10. $log_file = tempnam(sys_get_temp_dir(), 'php-curl-test');
  11. $fp = fopen($log_file, 'w+');
  12. fwrite($fp, "test");
  13. fclose($fp);
  14. $testfile_fp = fopen($test_file, 'w+');
  15. $ch = curl_init();
  16. curl_setopt($ch, CURLOPT_FILE, $testfile_fp);
  17. curl_setopt($ch, CURLOPT_URL, 'file://' . $log_file);
  18. curl_exec($ch);
  19. curl_reset($ch);
  20. curl_setopt($ch, CURLOPT_URL, 'file://' . $log_file);
  21. curl_exec($ch);
  22. curl_close($ch);
  23. fclose($testfile_fp);
  24. echo file_get_contents($test_file);
  25. // cleanup
  26. unlink($test_file);
  27. unlink($log_file);
  28. ?>
  29. ===DONE===
  30. --EXPECT--
  31. testtest
  32. ===DONE===