Edit report at https://bugs.php.net/bug.php?id=64644&edit=1
ID: 64644 Comment by: matteosistisette at gmail dot com Reported by: matteosistisette at gmail dot com Summary: Client-side abortion should be detected regardless of sending output Status: Not a bug Type: Bug Package: *General Issues Operating System: Linux PHP Version: 5.3.24 Block user comment: N Private report: N New Comment: Sh**, my last comment got silently discarded somehow!! Please talk to apache developers directly! If I were developing PHP, I would feel the urge to fix this issue (or call it "implement this feature" if you want, a basic vital feature whose lack is a huge issue) and if this is not possible due to a bug (or design flaw) in Apache I would strive to have them fix it. Previous Comments: ------------------------------------------------------------------------ [2013-04-14 00:42:33] ras...@php.net They are basically saying that we could try to hack around Apache and try to write directly to do direct socket ops on a socket opened and managed by Apache. Very bad idea. I don't know of any environment that attempts to do this. See this conversation about the same issue in Django, for example: http://stackoverflow.com/questions/6019145/how-do-i-detect-an-aborted- connection-in-django This isn't something we are going to address with hacks in PHP. ------------------------------------------------------------------------ [2013-04-13 23:41:08] matteosistisette at gmail dot com Response from Apache developers: https://issues.apache.org/bugzilla/show_bug.cgi?id=54842#c1 I'm not sure I fully understand it but it seems they say there actually IS a way PHP can figure out if the connection is closed without attempting to write. ------------------------------------------------------------------------ [2013-04-13 22:15:41] matteosistisette at gmail dot com Unbelievable. Then the huge design flaw is in Apache. ------------------------------------------------------------------------ [2013-04-13 21:59:18] ras...@php.net Apache handles the communication with the client browser and provides no mechanism for PHP to discover a client abort except on an actual write. ------------------------------------------------------------------------ [2013-04-13 21:56:04] matteosistisette at gmail dot com Ok, I see. The problem is that I hadn't disabled gzip in Apache, so the output wasn't being flushed until the end. As documented: """PHP will not detect that the user has aborted the connection until an attempt is made to send information to the client. Simply using an echo statement does not guarantee that information is sent, see flush().""" However, this is a huge design flaw. PHP definitely should be able to detect the client's abortion when it happens and not the next time it attempts to actually send output. Having to change the way output is handled just in order to be able to detect client disconnection is ridiculous (and not always feasible). I don't know if the server API currently provides a way for the server (i.e. Apache) to inform PHP of the client's disconnection, but if there is not it must be provided. ------------------------------------------------------------------------ The remainder of the comments for this report are too long. To view the rest of the comments, please view the bug report online at https://bugs.php.net/bug.php?id=64644 -- Edit this bug report at https://bugs.php.net/bug.php?id=64644&edit=1