Hi all,
I wonder if this is possible: I have a script that does things that
take time. In the first part of the script it does data checking and
other verifications, then comes the long part. I wish to be able to
send the result of the first part to the client, disconnect the HTTP
(so the client can do whatever they want), the script should then
continue with the rest of the time consuming tasks, at the end of
execution (or if an error occurs) an e-mail is sent.
The key here is that it's the script that aborts the connection. It
would be like putting the PHP process in the background to return the
hand to web server, which in turn would close the connection.
I already used the ignore_user_abo rt() to better control what's going
on in the script.
I've had a look at apache_child_te rminate() but it still waits that
the PHP script ends.
I don't want to use an HTTP refresh and for security reason I'd rather
avoid using a system() or exec() call.
My script is actually called by another script on another server
(using CURL)
I've also tried to add "Content-length: ..." in the HTTP headers and
use flush() to force the client to read the output and close the
connection when the byte count is reached. But it doesn't seem to work
that well... I can't either set a too short client timeout because it
needs to wait for the first part to be over (and it may depend on
server load.)
Your ideas are welcomed... of course if that could be implemented
inside PHP itself that would be great. I don't think Apache or not
matters...
-Philippe
[ 11abacus.com ]
I wonder if this is possible: I have a script that does things that
take time. In the first part of the script it does data checking and
other verifications, then comes the long part. I wish to be able to
send the result of the first part to the client, disconnect the HTTP
(so the client can do whatever they want), the script should then
continue with the rest of the time consuming tasks, at the end of
execution (or if an error occurs) an e-mail is sent.
The key here is that it's the script that aborts the connection. It
would be like putting the PHP process in the background to return the
hand to web server, which in turn would close the connection.
I already used the ignore_user_abo rt() to better control what's going
on in the script.
I've had a look at apache_child_te rminate() but it still waits that
the PHP script ends.
I don't want to use an HTTP refresh and for security reason I'd rather
avoid using a system() or exec() call.
My script is actually called by another script on another server
(using CURL)
I've also tried to add "Content-length: ..." in the HTTP headers and
use flush() to force the client to read the output and close the
connection when the byte count is reached. But it doesn't seem to work
that well... I can't either set a too short client timeout because it
needs to wait for the first part to be over (and it may depend on
server load.)
Your ideas are welcomed... of course if that could be implemented
inside PHP itself that would be great. I don't think Apache or not
matters...
-Philippe
[ 11abacus.com ]
Comment