Asynchronous upload via post?

Andre Garzia andre at andregarzia.com
Wed Jun 13 06:46:30 EDT 2007


Dave,

thanks for the tip! I use a similar approach for queueing downloads, it
didn´t occur to me that I could do the same thing with POST calls.

I noticed that the load command will queue connections to the same server
automatically, is this correct or am I dreaming?

Again, thanks for the hard work with LibURL! :-)

Cheers
andre


On 6/13/07, Dave Cragg <dave.cragg at lacscentre.co.uk> wrote:
>
>
> On 12 Jun 2007, at 17:11, David Bovill wrote:
>
> > You can load a url and you can do asynch ftp upload - but how about
> > if you
> > want to send a large amount of data to a remote location without
> > using ftp?
> > Can you do an "asynch post"? I guess you could do an asynch ftp
> > upload and
> > then a quick sychronous post on completion - any thoughts?
>
> If by "asynch" you mean keeping your application alive and running
> while the posts take place, it should be possible. The posts would
> occur sequentially, but your application should still be responsive
> during the transfers. Although "post" is described as "blocking" it
> only blocks the script it is called in. Other scripts can run at the
> same time.
>
> The approach taken would depend on your circumstances, but the idea
> is to set up some "out of synch" psuedo thread to handle the posts.
> The simplest way to do this might be using a "send ... in time"
> message. You can use liburlSetStatusCallback to display progress if
> needed.
>
> Rough idea (untested):
>
> local postUrlQ
> local asynchPostRunning = false
>
> on someHandler
> ---code
> -- code
>   asynchPost someUrl, someData
> -- code
> -- code
> end someHandler
>
> on asynchPost purl, pData
>   put pUrl & return after postUrlQ
>   if not asynchPostRunning then
>     send asynchPostHandler to me in 0 milliseconds
>   end if
> end asynchPost pUrl
>
> on asynchPostHandler
>   if not asynchPostRunning AND the number of lines of postUrlQ > 0 then
>         put line 1 of postUrlQ into tUrl
>         delete line 1 of tUrl
>         put true into asynchPostRunning
>         post pData to url pUrl
>         put it into tRetData
>         put the result into tRes
>         if tRes <> empty then
>             ## error handling
>             ## maybe send a callback message
>         else
>            ## success routine, do something with tData
>            ## maybe send callback
>         end if
>         put false into asynchPostRunning
>         if the number of lines of postUrlQ > 0 then
>            send asynchPostHandler to me in 0 milliseconds
>        end if
>   end if
> end asynchPostHandler
>
>
> _______________________________________________
> use-revolution mailing list
> use-revolution at lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your
> subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-revolution
>



More information about the use-livecode mailing list