php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #38553 Improved connection handling
Submitted: 2006-08-22 23:54 UTC Modified: -
Votes:4
Avg. Score:4.5 ± 0.9
Reproduced:3 of 3 (100.0%)
Same Version:2 (66.7%)
Same OS:3 (100.0%)
From: stirling dot andrew at gmail dot com Assigned:
Status: Open Package: Feature/Change Request
PHP Version: 5.1.5 OS: Any
Private report: No CVE-ID: None
 [2006-08-22 23:54 UTC] stirling dot andrew at gmail dot com
Description:
------------
I'm looking to be able to close a connection before the PHP script has finished. An example of this functionality's application:
1. XMLHttpRequest requests PHP page 'setup.php';
2. setup.php checks request, approves that it is possible, and outputs a positive response, then closes the connection.
3. setup.php then does time-intensive setup procedure for later use.

This would allow this things to be started by an XMLHttpRequest, but not require the client to have to hang around waiting before it can return a positive or negative response. While the approval will come within less than a second, the rest of the script might take up to 10 seconds to be finished during a peak period. Having to wait for the full script to run is less than ideal.

Reproduce code:
---------------
<?php
// Pseudo-php.
function check_allowed( $id );
function setup_data( $id );

if( check_allowed($_GET['id']) )
  $xml = '<response approved=1 />';
else
  $xml = '<response approved=0 />';

echo $xml;
flush();
close_connection(); // Requested feature
setup_data( $_GET['id'] );
?>

Expected result:
----------------
The XMLHttpRequest object will be ready to use as soon as the connection is closed at close_connection(). While I have included a flush() call in the above example, ideally close_connection() should include an output buffer flush.

Actual result:
--------------
N/A (Feature does not exist, and simply using ignore_user_abort() and flush() is not sufficient)

Patches

Pull Requests

 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Wed Dec 11 14:02:33 2024 UTC