Had the old problem trying to download streamed documents over SSL yesterday hear are the headers I needed to send to fix the php script
header("Expires: " . Date("r"));
header("Cache-Control: public, must-revalidate");
header("Content-Length: " . strlen("$buffer}"));
header("Content-Disposition: attachment; filename=$filename");
Some people have reported that just setting the pragma header works for them but I needed all of these headers.