curl_setopt_basic002.phpt 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. --TEST--
  2. curl_setopt basic tests with CURLOPT_STDERR.
  3. --CREDITS--
  4. Paul Sohier
  5. #phptestfest utrecht
  6. --EXTENSIONS--
  7. curl
  8. --FILE--
  9. <?php
  10. include 'server.inc';
  11. $host = curl_cli_server_start();
  12. // start testing
  13. echo "*** Testing curl_setopt with CURLOPT_STDERR\n";
  14. $temp_file = tempnam(sys_get_temp_dir(), 'CURL_STDERR');
  15. $handle = fopen($temp_file, 'w');
  16. $url = "{$host}/";
  17. $ch = curl_init();
  18. curl_setopt($ch, CURLOPT_VERBOSE, 1);
  19. curl_setopt($ch, CURLOPT_STDERR, $handle);
  20. $curl_content = curl_exec($ch);
  21. fclose($handle);
  22. unset($handle);
  23. var_dump(preg_replace('/[\r\n]/', ' ', file_get_contents($temp_file)));
  24. @unlink($temp_file);
  25. ob_start(); // start output buffering
  26. $handle = fopen($temp_file, 'w');
  27. curl_setopt($ch, CURLOPT_URL, $url); //set the url we want to use
  28. curl_setopt($ch, CURLOPT_STDERR, $handle);
  29. $data = curl_exec($ch);
  30. ob_end_clean();
  31. fclose($handle);
  32. unset($handle);
  33. var_dump(preg_replace('/[\r\n]/', ' ', file_get_contents($temp_file)));
  34. @unlink($temp_file);
  35. curl_close($ch);
  36. ?>
  37. --EXPECTF--
  38. *** Testing curl_setopt with CURLOPT_STDERR
  39. string(%d) "%S"
  40. string(%d) "%S"