Re: [PHP] curl help or other suggestion
As it turns out curl_multi does not block. I was able to use that plus connection tracking to solve my problem. Thanks Ash and Andrew. Mike > On Thu, Jun 17, 2010 at 9:05 AM, Michael Alaimo > wrote: >> I am trying to use register_shutdown_function. Â Previous to the script >> shutting down I use curl to grab a website. >> >> Basically I want to know if the user has hit the stop button or left the >> page prematurely. >> >> The only problem is that curl runs and finishes its call before the >> shutdown function is called. Â Because of this I Â have no way to know >> if >> the user canceled the request somehow. Â Any suggestions? >> >> Mike > > I don't know that it will affect cURL, but if you are just looking to > log completed versus abandoned requests, this might help: > > http://www.php.net/manual/en/function.ignore-user-abort.php > > Andrew > > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] curl help or other suggestion
On Thu, Jun 17, 2010 at 9:05 AM, Michael Alaimo wrote: > I am trying to use register_shutdown_function. Previous to the script > shutting down I use curl to grab a website. > > Basically I want to know if the user has hit the stop button or left the > page prematurely. > > The only problem is that curl runs and finishes its call before the > shutdown function is called. Because of this I have no way to know if > the user canceled the request somehow. Any suggestions? > > Mike I don't know that it will affect cURL, but if you are just looking to log completed versus abandoned requests, this might help: http://www.php.net/manual/en/function.ignore-user-abort.php Andrew -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] curl help or other suggestion
On Thu, 2010-06-17 at 09:37 -0400, Michael Alaimo wrote: > > On Thu, 2010-06-17 at 09:05 -0400, Michael Alaimo wrote: > > > >> I am trying to use register_shutdown_function. Previous to the script > >> shutting down I use curl to grab a website. > >> > >> Basically I want to know if the user has hit the stop button or left the > >> page prematurely. > >> > >> The only problem is that curl runs and finishes its call before the > >> shutdown function is called. Because of this I have no way to know if > >> the user canceled the request somehow. Any suggestions? > >> > >> Mike > >> > >> > >> > > > > > > You can't. When a visitor closes their browser, or stops the page from > > completing its loading, no message is sent to the server, so your PHP > > script won't know about it. > > > > The only way I know of currently to check for this is use some form of > > regular check-in, with Ajax or something, that calls home at regular > > intervals to inform your script that it is indeed still connected. If it > > fails to call home in time it either means there's lag on the connection > > or they broke it. > > > > Thanks, > > Ash > > http://www.ashleysheridan.co.uk > > > > > I wish that curl would just stop processing. I think you can use > connection tracking to know what the user has done. I just cannot use it > with my current situation as the code is. > > Mike > If this situation is occurring often, maybe a re-think of the structure of your app. What is cURL fetching? Is it something that you can cache at your end, like an RSS feed, etc? If so, maybe use the local cache and only refresh if the local copy is too old. Thanks, Ash http://www.ashleysheridan.co.uk
Re: [PHP] curl help or other suggestion
> On Thu, 2010-06-17 at 09:05 -0400, Michael Alaimo wrote: > >> I am trying to use register_shutdown_function. Previous to the script >> shutting down I use curl to grab a website. >> >> Basically I want to know if the user has hit the stop button or left the >> page prematurely. >> >> The only problem is that curl runs and finishes its call before the >> shutdown function is called. Because of this I have no way to know if >> the user canceled the request somehow. Any suggestions? >> >> Mike >> >> >> > > > You can't. When a visitor closes their browser, or stops the page from > completing its loading, no message is sent to the server, so your PHP > script won't know about it. > > The only way I know of currently to check for this is use some form of > regular check-in, with Ajax or something, that calls home at regular > intervals to inform your script that it is indeed still connected. If it > fails to call home in time it either means there's lag on the connection > or they broke it. > > Thanks, > Ash > http://www.ashleysheridan.co.uk > I wish that curl would just stop processing. I think you can use connection tracking to know what the user has done. I just cannot use it with my current situation as the code is. Mike -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] curl help or other suggestion
On Thu, 2010-06-17 at 09:05 -0400, Michael Alaimo wrote: > I am trying to use register_shutdown_function. Previous to the script > shutting down I use curl to grab a website. > > Basically I want to know if the user has hit the stop button or left the > page prematurely. > > The only problem is that curl runs and finishes its call before the > shutdown function is called. Because of this I have no way to know if > the user canceled the request somehow. Any suggestions? > > Mike > > > You can't. When a visitor closes their browser, or stops the page from completing its loading, no message is sent to the server, so your PHP script won't know about it. The only way I know of currently to check for this is use some form of regular check-in, with Ajax or something, that calls home at regular intervals to inform your script that it is indeed still connected. If it fails to call home in time it either means there's lag on the connection or they broke it. Thanks, Ash http://www.ashleysheridan.co.uk
[PHP] curl help or other suggestion
I am trying to use register_shutdown_function. Previous to the script shutting down I use curl to grab a website. Basically I want to know if the user has hit the stop button or left the page prematurely. The only problem is that curl runs and finishes its call before the shutdown function is called. Because of this I have no way to know if the user canceled the request somehow. Any suggestions? Mike -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php