Advertisement
Guest User

Dynom

a guest
May 10th, 2009
603
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.08 KB | None | 0 0
  1. --TEST--
  2. Test curl_setopt() CURLOPT_FILE readonly file handle
  3. --SKIPIF--
  4. <?php if (!extension_loaded("curl")) print "skip"; ?>
  5. --FILE--
  6. <?php
  7. /*
  8. * Description : Adds a file which stores the received data from curl_exec();
  9. * Source code : ext/curl/multi.c
  10. * Test documentation: http://wiki.php.net/qa/temp/ext/curl
  11. */
  12.  
  13. // Figure out what handler to use
  14. if(!empty($_ENV['PHP_CURL_HTTP_REMOTE_SERVER'])) {
  15.  
  16. // Use the set Environment variable
  17. $url = $_ENV['PHP_CURL_HTTP_REMOTE_SERVER'];
  18.  
  19. } else {
  20.  
  21. // Create a temporary file for the test
  22. $tempname = tempnam(sys_get_temp_dir(), 'CURL_HANDLE');
  23. $url = 'file://'. $tempname;
  24.  
  25. // add the test data to the file
  26. file_put_contents($tempname, "Hello World!\nHello World!");
  27. }
  28.  
  29.  
  30. $tempfile = tempnam(sys_get_temp_dir(), 'CURL_HANDLE');
  31.  
  32. $ch = curl_init($url);
  33. $fp = fopen($tempfile, "r"); // Opening 'fubar' with the incorrect readonly flag
  34. curl_setopt($ch, CURLOPT_FILE, $fp);
  35. curl_exec($ch);
  36. curl_close($ch);
  37. is_file($tempfile) and unlink($tempfile);
  38. ?>
  39. --EXPECT--
  40. Warning: (%s)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement