cURL / Mailing Lists / curl-and-php / Single Mail

curl-and-php

(no subject)

From: Dave Withnall <withnall_at_connexus.net.au>
Date: Wed, 22 May 2002 17:07:03 +1100

Greetings,

I've encounted the following problem.
when using the curl extensions built into php it works - i can get webpages
etc etc.
however whenever i try to use any of the functions which save things to files

 eg - curl_setopt($ch, CURLOPT_WRITEHEADER, $header);
or curl_setopt($ch, CURLOPT_FILE, $output);

the script times out with no info written into the file (the file is created
but its just 0 bytes long - and the webserver doesn't close its connection to
it so i have to shut down the server to delete them - indicates something might
have crashed)

however if i do the following i can get an output written to a file
$test = curl_exec($ch);
fwrite($output, $test);

so the only way I can write the headers to a file is to do this
curl_setopt($ch, CURLOPT_NOBODY, True);
with the above test.

do you have any ideas as to why this would be happening? especially as I can
write to the files using alternative methods.

a complete code list is below

Regards
D.

<?php
$ch = curl_init();

$output = fopen("tmp\\out", "w+");
$header = fopen("tmp\\header", "w+");

curl_setopt($ch, CURLOPT_VERBOSE, 1); // Spit out everything
curl_setopt($ch, CURLOPT_MUTE, True); // Show LibcURL Output
curl_setopt($ch, CURLOPT_HEADER, True); // Show Headers
curl_setopt($ch, CURLOPT_NOBODY, False); // Hide Body

curl_setopt($ch, CURLOPT_FOLLOWLOCATION, True); // Redirects on

curl_setopt($ch, CURLOPT_WRITEHEADER, $header);

curl_setopt($ch, CURLOPT_URL, "http://www.google.com/");

curl_setopt($ch, CURLOPT_FILE, $output);

curl_exec($ch);
curl_close($ch);

fclose($output); // Close the file
fclose($header);

unset($ch); // Clean up
?>

_______________________________________________________________

Don't miss the 2002 Sprint PCS Application Developer's Conference
August 25-28 in Las Vegas -- http://devcon.sprintpcs.com/adp/index.cfm
Received on 2002-05-22