Will sending an HTTP call execute on a remote server even though it times out on mine

If I do the do the following:


ini_set('default_socket_timeout', 1);
file_get_contents("http://www.someothersite.com");

Will the remote site completely execute the server side script even though my connection times out? I am not so much asking about delivering HTML as I am executing the server side code such as PHP/ASP/CGI etc.

I guess my question is; Is there something in the HTTP protocol that checks that the requester is still “there”.

If I for instance go to a site in my browser and quickly click the stop button - is all the server side code executed or will it somehow know that I have aborted the connection and stop executing the script to save resources?

AFAIK the default_socket_timeout will only timeout a connection if it can’t be established (remote host doesn’t react).
Once the connection has been established it won’t time out, so you will always get the complete contents.
I might be wrong though …

As far as disconnecting while retrieving content goes, there is a php.ini setting that can change this (either continue processing the script when the user presses the “stop” button in his browser, or stop processing the script). Can’t remember which setting it is, but I’m sure it’s there :slight_smile:

ignore_user_abort
This indicates to me that there might be a chance that the request will not be executed till it’s end.
Not so cool, though :-/

Yes, that’s the one :slight_smile:

Why not cool? Very cool!
If a user presses the stop button in his/her browser the PHP process will be killed, freeing up resources for other requests :slight_smile:
What’s the point of processing a request when no-one will ever see the output?

I wouldn’t use ignore_user_abort for output. But I have used it occasionally for file writing to log files and database scripts before when I wanted to make sure the script didn’t stop mid-way and muck things up.

Ist it cool when it stops in the middle of your data insertion and you get corrupted data?
I don’t think so.
The client should never ever tell the server what to do or not.

Hm, didn’t think of it that way.
However, I’ve been programming PHP for about 9 years now, and I’ve never exprerienced the problem you’re describing, and have made my share of websites, so I’m not that concerned about that I guess.