14

Suppose, I enter a URL in my browser and browser submits the HTTP request. The remote HTTP server accepts the request and initiates a long task to serve the request.

If I terminate the request before it is complete (for example, press Esc or in Firefox), how is the request closed? Will the browser communicate this abort request to the server (I think it doesn't)?

Presuming no, upon completion of the long task, what will the server do with the result? Does it send it back anyway? If it does, what will happen? Does it reach till my PC? Or gets lost on the way?

This is just for my curiosity.

Thanks for your time :)

1
  • 2
    Have you tried running a wireshark capture? It makes it real easy to see what one computer sends to another over the network.
    – racyclist
    Jun 3, 2010 at 15:59

2 Answers 2

9

Well, it all depends on what the server is doing. Typically, it won't "detect" the terminated request until a send is attempted. At that point, the script will get a user_abort message from the web server (in php, you can tell it to ignore the user aborts with ignore_user_abort(true);). Without attempting to send data to the client, there's no way for the server to know that the request was aborted.

When it tries to send the request to the closed TCP connection, what happens is completely dependent on the server software. Apache works like this: If the sent data is still while a dynamic script is processing, it will tell the script about the abort and let it handle it how it wants (PHP --by default-- terminates). If the script is done, or it's a static file request, it will just ignore the closed connection and return.

-2

I think it is to be thought of electricity kind of thing. charge. when some connection terminates, the data being sent is a charge, it just disappears since no listening socket available for that particular transfer. only if there is a socket, some communication happens.

Example:

We hit http://localhost for apache2 httpd. suppose it is not running. Browser opens a socket, sends a message to port 80 (default) and looks if there is any response. Since there is no listener as apache is not running, this ping request does not get any response at all. at least 200 ok or any kind of hand shake at all. then what happens to our ping ? http sends some thing : like GET http://localhost 80... etc. what happens to this line ? GET http://localhost 80? it is just a charge and disappears.

This is just my belief, and we should first refer to TCP for more clarity. Only then, we can understand how Internet protocol and the subsequent http behave. Ultimately, there looks like no concrete definition for a premature terminated http request. That is why it is called premature termination.

1
  • 2
    While poetic, perhaps, this is inexact, and not a particularly useful way to consider the impact of this. Dec 28, 2013 at 0:22

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .