Re: Large File Not Being Sent To Client
- From: Jerry Stuckle <jstucklex@xxxxxxxxxxxxx>
- Date: Fri, 09 Mar 2007 21:41:13 -0500
John C. Frickson wrote:
On 2007-03-09 10:28, John C. Frickson wrote:My company produces reports for our customers in PDF format. I have a
php script that verifies login status and access rights, and sends
the pdf to the client using readfile().
This has worked fine until recently. One of our customers' reports
is 10.6MB, and the customer never receives it and I can't get it
either. I checked the Apache access_log, and it shows varying
amounts of bytes being sent, but always close to 10MB.
I tried changing the php script to do fopen(), fread(), echo,
ob_flush() and flush(). After each flush, I write a message to a log
file. The messages in the log file stop at 10MB, as if the php script
is hung.
Using a network monitor, I see the connection being established, the
HTTP GET being sent, but no content coming back.
PHP version is 5.1.2
Apache is 2.2.3
OS is SuSE Linux Enterprise Server 10.0 - 64bit
Current test version looks like this:
ini_set("output_buffering", "0");
ini_set("implicit_flush", "1");
ini_set("memory_limit", "100M");
ini_set("max_execution_time", "600");
$lth = 0;
$in = fopen($path, "r");
while (!feof($in)) {
$data = fread($in, 8192);
$lth += strlen($data);
$errLog->WriteLog("Read $lth bytes" , "debug.txt");
echo $data;
$errLog->WriteLog("After echo" , "debug.txt");
ob_flush();
$errLog->WriteLog("After ob_flush" , "debug.txt");
flush();
$errLog->WriteLog("After flush" , "debug.txt");
}
$errLog->WriteLog("Got EOF", "debug.txt");
fclose($in);
$errLog->WriteLog("End of Script - read $lth bytes", "debug.txt");
The last five lines of the debug.txt log file say:
Read 10223616 bytes
After echo
After ob_flush
After flush
Read 10231808 bytes
After echo
So it's never returning from the ob_flush() call. Time from first
log entry to last is about 1 second.
Any ideas?
John
I noticed I didn't have a "Content-Length" header, so I added it
and it's now working. Even without the header, it should have
worked anyway, shouldn't it?
Not reliably. There is a reason for the Content-Length header - to let the browser know how much to expect.
Without the header the browser is free to figure on it's own how long the data should be (no browser I know of allows "unlimited length). And evidently you finally exceeded the browser default.
--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex@xxxxxxxxxxxxx
==================
.
- Follow-Ups:
- Re: Large File Not Being Sent To Client
- From: John C. Frickson
- Re: Large File Not Being Sent To Client
- References:
- Large File Not Being Sent To Client
- From: John C. Frickson
- Re: Large File Not Being Sent To Client
- From: John C. Frickson
- Large File Not Being Sent To Client
- Prev by Date: Re: c-sharp
- Next by Date: Re: how to securely store a record index when editing a mysql record
- Previous by thread: Re: Large File Not Being Sent To Client
- Next by thread: Re: Large File Not Being Sent To Client
- Index(es):
Relevant Pages
|