libRevCurl
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller
-
- Posts: 179
- Joined: Sat Apr 08, 2006 11:08 pm
- Contact:
libRevCurl
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
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
-
- Posts: 179
- Joined: Sat Apr 08, 2006 11:08 pm
- Contact:
-
- VIP Livecode Opensource Backer
- Posts: 977
- Joined: Sat Apr 08, 2006 7:47 am
- Contact:
Hi Ivan,
Which problems are you running into with the revXMLRPC commands?
Jan Schenkel.
Which problems are you running into with the revXMLRPC commands?
Jan Schenkel.
Quartam Reports & PDF Library for LiveCode
www.quartam.com
www.quartam.com
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
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
Thanks, for the Curl lib, very cool,
-
- VIP Livecode Opensource Backer
- Posts: 977
- Joined: Sat Apr 08, 2006 7:47 am
- Contact:
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.
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.
Quartam Reports & PDF Library for LiveCode
www.quartam.com
www.quartam.com
-
- Posts: 179
- Joined: Sat Apr 08, 2006 11:08 pm
- Contact:
-
- Posts: 179
- Joined: Sat Apr 08, 2006 11:08 pm
- Contact:
Ivan, for a non-blocking POST:
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.
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.
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.
Hi Mark,
Thanks for the code and advice.
Ivan
Thanks for the code and advice.
Ivan
Mark Smith wrote:Ivan, for a non-blocking POST:
You might also checking to see if <curl.error(tCurl)> returns empty, before cleanup.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.
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.