# Something broke in curl

- Thread: https://externals.io/message/44469
- Original archive: https://news-web.php.net/php.internals/44469
- Started by Rasmus Lerdorf on 2009-06-26T17:26:04+00:00
- Messages: 1
- Reply by email to internals@lists.php.net
- More for agents: search with https://externals.io/search.md?q={query} · JSON API at https://externals.io/api · documentation at https://externals.io/llms.txt

---

## #44469 — Rasmus Lerdorf — 2009-06-26T17:26:04+00:00

URL: https://externals.io/message/44469#44469

I have been looking through the curl changes.  Nothing really jumps out
at me though.  Jani's curl handle change perhaps?  Doesn't seem like
that would cause this.

Anyway, here is a standalone little test case:

<?php
$url = 'http://slowgeek.com/test.xml';
$cfile = '/var/tmp/test_'.$prefix.md5($url).'.xml';
$ch = `curl_init()`;
curl_setopt($ch, CURLOPT_FILE, $fp = fopen($cfile,'w'));
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 30);
curl_setopt($ch, CURLOPT_TIMEOUT, 60);
curl_setopt($ch, CURLOPT_URL, $url);
$status = curl_exec($ch);
if(!$status) echo curl_error($ch);
fclose($fp);  // No implicit flush here?
curl_close($ch);
$data = file_get_contents($cfile);
var_dump($data);  // 0 bytes here
fflush($fp);      // fflush after the fclose fixes it??
$data = file_get_contents($cfile);
var_dump($data);  // full contents here

In 5.2.9 this prints out the xml twice.  In 5.2.10 and our current 5.3
code, it prints out 0 bytes for the first var_dump.

This took down my Slowgeek site yesterday and was a bitch to debug and I
consider this a rather critical problem.

-Rasmus
