I open the file with:
Code: Select all
$fp = fopen($path.$dataї'realname'], "r");Code: Select all
// Read the actual file, 4k at a time
while (!feof($fp)) {
if (connection_status() != 0) {
// if (connection_aborted()) {
// Download cancelled
break;
}
$buffer = fread($fp, 4096);
print $buffer;
}
fclose($fp);I did some packet capturing and found that when a page is loaded normally, the server sends a "fin" when it is done. If the user presses stop in his/her browser before the page has finished loading, the client sends a "fin" and php stops. However, when a user cancels a download, the client only sends a bunch of packets with the "rst" flag set. I believe that as a result, php is not seeing the connection as aborted and continues to read the file even though apache has stopped sending the data to the client. Does php just not get notified that the client has tried to reset the connection and it should stop working on a page for the client? It seems like it ought to stop in that case.
I hope this is clear, if I need to clearify something let me know. I'm also not real solid in my tcp connection protocol, so I may be way off in what I think should happen with a rst. I would really appreciate some help with getting this cleared up.