php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #39478 connection_abort() Fails when using the CGI Interface.
Submitted: 2006-11-12 11:53 UTC Modified: 2006-11-12 19:01 UTC
Votes:1
Avg. Score:5.0 ± 0.0
Reproduced:0 of 0 (0.0%)
From: trustpunk at gmail dot com Assigned:
Status: Not a bug Package: CGI/CLI related
PHP Version: 5.2.0 OS: Windows
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: trustpunk at gmail dot com
New email:
PHP Version: OS:

 

 [2006-11-12 11:53 UTC] trustpunk at gmail dot com
Description:
------------
The connection_aborted() doesn't work under CGI. I discovered
this bug when I was coding a current download count script.

The "ISAPI/Apache Modules" work fine with this function.

Reproduce code:
---------------
I used the following code to output some text in a slow maner,
than I stopped it to see if the file is written.

The file is written under the ISAPI/Apache Modules, but it
isn't written when using CGI. Why is that?

<?php
ignore_user_abort(1);

// Type a message to animate on the person's browser.

$string = "This dummy text will be shown every second untill it's finished. You should<br>
close the browser while it's typing on your screen and check message.txt";
      
$output = str_split($string, 1);

for ($n=0; $n < count($output); $n++) {

    set_time_limit(0);
    
    flush();
    ob_end_flush();
    sleep(1);
    
    echo $output[$n];

    if (connection_aborted()) {
        
        $fp = fopen("message.txt", "w");
        fwrite($fp, "Download Aborted! No!!!!!");
        fclose($fp);
        exit;
    }
}
?>



Expected result:
----------------
IF the condition of connection_aborted() is TRUE, it should
write message.txt with some text in it.

Actual result:
--------------
Nothing is written!

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2006-11-12 19:01 UTC] tony2001@php.net
This happens because CGI is not a part of the web-server, so there is CGI executeble is executed first and then you got it's output through the web-server.
There is no chance to detect if connection has been aborted when running in CGI mode.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Nov 01 01:01:28 2024 UTC