libURLSetStatusCallback: is there a simpler way?

David Bovill david at openpartnership.net
Mon Feb 19 07:04:48 EST 2007


I am getting errors with fetching data from a web server. The "symptoms"
are:

On occassion "put url someURL in someXML" return empty - that is someXML is
empty. This happens when I click a couple of times on different items in the
GUI in succession resuling in an error.

I think though it is hard to debug, that this is because I am using "load"
and mixing these calls with blocking call like the above when I want to get
the data now.

I am sure I read somewhere in the docs that multiple calls to the same URL
can cause problems - is this right ??? In which case I should do a check
with urlstatus(someURL) before calling the url?

URLStaus?
Well if this is the cause of the problem I could not fix it - as AFAIK
urlstatus(someURL) only allows you to check the status of a url you know. In
my case the previous url would be different from the one I am about to call
- that is the script is about to check:

    www.mydomain/new.cgi

and I have a number of

    load url "http://www.mydomain/someimage.png"

in progress. My guess is that because they share the same domain - the call
to the cgi is returning empty - but that I cannot check the urlstatus before
the call to the cgi as the urlstatus of new.cgi is empty and without
tracking all the "load" calls in my script there is no way to find out how
many urls are currenty loading but no finished loading - this is surely a
deficiency of the "urlstatus" function?

The hard way?
Before embarking on this I thought I would check in to see if there is an
easier way... but this is what I am thinking of doing...

If I set "libURLSetStatusCallback" then I could effectively log all calls to
urls that are in the process of loading but not in the cache yet. That is
the following status commands would be (effectively) "sent" back from the
server:

"queued": on hold until a previous request to the same site is completed
> "contacted": the site has been contacted but no data has been sent or
> received yet
> "requested": the URL has been requested



And I could then store the url"s of the pending urls yet to be cached by the
"load" function?

The easy way?
It would seem there must be an easier way? Am I right about the source of
the error?
The only other way I can think of doing this is simply not to mix "load" and
"get url..." from the same server. If I used another "load" if would be
place in th cue. However then I loose my ability to "prioritize" calls to
certain urls and all 500 thumbnails would have to load before a user click
shows the full image...



More information about the Use-livecode mailing list