Previous: Using Getopt
Flusspferd provides an interface for libcurl. libcurl is a very extensive data transfer library. It supports HTTP(s), FTP, SSH and several other protocols with different authentication mechanisms and it is quite popular.
Flusspferd's cURL module is very similar to the interface of libcurl and people familiar with using libcurl in other languages should feel right at home. But names are converted into Javascript style and some functions and options were omitted or hidden (see implementation notes).
Using the cURL module is straight forward
const cURL = require('curl');
var c = new cURL.Easy();
c.options.url = 'http://www.google.com';
c.perform();
This should print the html data from google.com. Of course you usually do not want to print the data. You can add a callback to handle the retrieved data
var buffer;
c.options.writefunction = function(data,size) {
buffer = data.decodeToString();
return data.length; // return data.length if everything is ok.
}
c.options.url = 'http://www.google.com';
c.perform();
// do something with buffer
print("Got this: " + buffer);
cURL provides a lot of options and you can fine tune your requests. See cURL.Easy::options for more.
Contact us at team -AT- flusspferd -DOT- org or as described on our homepage.
Generated on Thu Feb 4 23:05:12 2010 for Flusspferd by
1.6.1