views:

169

answers:

4

If a page is called that requires a lot of processing and the user clicks stop before the end, does the browser simply stop the request at the client side?

Or is a 'stop' message sent to the server, i.e. is the processing cancelled?

+8  A: 

No message is sent to the server when that happens. When the user presses the stop button, the browser just halts the rendering of the page and ignore any further response= from the server.

If the request has already been sent to the server, the server will usually continue executing it. However, depending on the server's implementation, may detect the dropped connection. Meaning you can not rely on the fact that it will continue in every case.

Darin Dimitrov
The server, however, can detect the dropped connection. Whether the server will continue executing after the connection has dropped depends on the implementation of the server and you can not rely on the fact that it will continue in every case.
Rithiur
@Rithiur, I agree with you, it's a nice remark from your part.
Darin Dimitrov
I have incorporated the comment into the answer
Jon Winstanley
+3  A: 

There's no "STOP" messages/requests defined in HTTP, since HTTP is stateless, and stopping a request would require you to know its ID. Quite naturally, as soon as HTTP request hits a server, it cannot be stopped from the outside world.

Anton Gogolev
+2  A: 

The server will still process the request. If you are using Visual Studio you can attach to the IIS worker processes to see that this is the case. Debug > Attach to Process

+3  A: 

Actually it kind of sends a "stop message" by closing the connection. This is true only if it is still waiting for output from the main request (not when finished downloading content and started loading images and stuff). So you can detect if the user presses the stop button OR there is some trouble with the connection, when you get connection closed message.

Here is some info on PHP's user manual: http://php.net/manual/en/features.connection-handling.php

On a side note - it always depend on the browser implementation and there is no certain way to be sure if the user pressed the stop button or the connection just dropped.

bisko
This is indeed a very important and often forgotten detail. While there is no explicit "stop" command, the dropped connection CAN be detected. This will, for example, abort currently running PHP script by default. This does not happen immediately as the user presses stop, so the script may finish executing even if stop is pressed (as the user may simply be waiting on the server's output buffer and not the script itself).Directly from the pasted url: "The default behaviour is however for your script to be aborted when the remote client disconnects."
Rithiur