expose low level curl.

This commit is contained in:
Miao Jiang 2013-02-19 20:12:33 +08:00
parent d25438bdf0
commit 02ba0f25d3
5 changed files with 48 additions and 12 deletions

28
examples/low-level.js Normal file
View file

@ -0,0 +1,28 @@
var Curl = require('../lib/Curl')
var p = console.log;
var url = process.argv[2];
var curl = new Curl();
if (!url)
url = 'www.yahoo.com';
curl.setopt('URL', url);
curl.setopt('CONNECTTIMEOUT', 2);
// on 'data' must be returns chunk.length, or means interrupt the transfer
curl.on('data', function(chunk) {
return chunk.length;
});
curl.on('error', function(e) {
curl.close();
});
curl.on('end', function() {
curl.close();
});
curl.perform();