Page 1 of 1
libRevCurl
Posted: Sat Aug 09, 2008 7:57 pm
by Mark Smith
I've released a beta version of a library that wraps the curl command line tool.
It's not intended as a replacement for libUrl, but has been developed to cover situations tha libUrl either doesn't at all, or doesn't quite:
http PUT,HEAD,DELETE,OPTIONS,TRACE
https - there still seem to be problems with secure sockets in Revolution, so this just gets around it.
http uploads from files on disc.
I won't try to describe the interface here, but I've included a short intro pdf with examples, and a dictionary. There's a lot of stuff in the library that I haven't yet documented, and some things I haven't yet been able to test, but they can be found if anyone wants to have a look at the code - a look at the curl man page might also give clues.
It also has a non-blocking approach which allows multiple parallel requests - but may take a little care to manage.
It only covers http operations for now, but I intend to include ftp and others in future.
All comments and suggestions welcome.
Mark
Posted: Sat Aug 09, 2008 8:00 pm
by Mark Smith
Posted: Tue Sep 16, 2008 7:57 pm
by Ivan Wong
Hi Mark,
Thanks for this library.
Is there any way to get it to work with Rev's built-in xmlrpc calls?
Regards,
Ivan
Posted: Wed Sep 17, 2008 12:02 pm
by Janschenkel
Hi Ivan,
Which problems are you running into with the revXMLRPC commands?
Jan Schenkel.
Posted: Wed Sep 17, 2008 6:34 pm
by Ivan Wong
Hi Jan,
I managed to get revXMLRPC working separately. I also got revlibcurl working (but not for XML-RPC calls).
I am interested in using revlibcurl for making non-blocking calls to an xmlrpc blog server, as I found when posting a large quantity of requests via revXMLRPC it suddenly slows down after several requests.
I actually have 2 questions here:
1) How to set the equivalent of revXMLRPC_CreateRequest, revXMLRPC_SetMethod, revXMLRPC_AddParam & revXMLRPC_Execute for CURL
2) How to use revlibcurl for non-blocking calls (I could not find any examples in Mark's documentation)
Thanks,
Ivan
nice
Posted: Fri Sep 19, 2008 12:01 am
by reelstuff
Thanks, for the Curl lib, very cool,
Posted: Fri Sep 19, 2008 7:02 am
by Janschenkel
Hi Ivan,
The 'revXMLRPC' library was built on top of libURL and also offers direct socket communication (so that you can take care of the connection and leave it open long-term, which is something you can't do in libURL).
Anyway, as the library was written in Revolution, you should be able to make a copy, take it apart and replace the single call to the 'post' command with a call to the equivalent Curl lib command. Okay, you may have to replace a few more things in the same handler to set and read HTTP-headers, but it's not rocket science.
To see the Revolution script that offers the revXMLRPC calls, open the Message Box, go to the Back Scripts section, tick the checkbox do show Revolution UI back scripts and doubleclick the line 'revXMLRPC' - then select all, copy and paste into the script of a new stack. Finally replace 'revXMLRPC_' with 'curlXMLRPC_' and go to work
Hope this helped,
Jan Schenkel.
Posted: Wed Sep 24, 2008 9:26 am
by IvanWong
Hi Jan,
Thanks for the reply. I'll give it a shot.
Cheers,
Ivan
Posted: Fri Sep 26, 2008 12:42 am
by Mark Smith
Sorry, wasn't paying attention for the last few days.
I've never played with the xml-rpc stuff, so I'll have a look, and see what I can find.
Best,
Mark
Posted: Fri Sep 26, 2008 2:05 am
by Mark Smith
Ivan, for a non-blocking POST:
Code: Select all
put curl.new() into tCurl
curl.setUrl tCurl, "http://someserver.com/somepath"
curl.setPostData tCurl, tPostData
curl.execute tCurl
-- at this point, curl just gets on with it, and your script continues...
repeat until curl.done(tCurl)
wait 20 ticks with messages --always 'with messages' or everything stops!
put curl.prog(tCurl) & "%" -- put 'percent complete' into the message box
end repeat
put curl.response(tCurl) -- show the server response
curl.cleanup tCurl -- free up the resources used by this curl instance.
You might also checking to see if <curl.error(tCurl)> returns empty, before cleanup.
Whilst all this is happening, the user of your app can continue working, including starting other curls.
Handling many concurrent instances can get a bit tricky, but I'm doing it in more than one app quite successfully.
However, Jan is right about the built-in XML-RPC library. It uses libUrl (not surprisingly). A brief look at the XML-RPC script tells me that you could certainly make it use curl, but it's not just simply a case of replacing the call to libUrl's post handler.
Posted: Thu Oct 09, 2008 6:45 pm
by IvanWong
Hi Mark,
Thanks for the code and advice.
Ivan
Mark Smith wrote:Ivan, for a non-blocking POST:
Code: Select all
put curl.new() into tCurl
curl.setUrl tCurl, "http://someserver.com/somepath"
curl.setPostData tCurl, tPostData
curl.execute tCurl
-- at this point, curl just gets on with it, and your script continues...
repeat until curl.done(tCurl)
wait 20 ticks with messages --always 'with messages' or everything stops!
put curl.prog(tCurl) & "%" -- put 'percent complete' into the message box
end repeat
put curl.response(tCurl) -- show the server response
curl.cleanup tCurl -- free up the resources used by this curl instance.
You might also checking to see if <curl.error(tCurl)> returns empty, before cleanup.
Whilst all this is happening, the user of your app can continue working, including starting other curls.
Handling many concurrent instances can get a bit tricky, but I'm doing it in more than one app quite successfully.
However, Jan is right about the built-in XML-RPC library. It uses libUrl (not surprisingly). A brief look at the XML-RPC script tells me that you could certainly make it use curl, but it's not just simply a case of replacing the call to libUrl's post handler.