Improve performance.
This commit is contained in:
parent
02ba0f25d3
commit
1061e177b2
6 changed files with 29 additions and 9 deletions
|
@ -1,4 +1,4 @@
|
|||
var Curl = require('../lib/Curl')
|
||||
var Curl = require('..').Curl
|
||||
|
||||
var p = console.log;
|
||||
var url = process.argv[2];
|
||||
|
@ -6,23 +6,26 @@ var url = process.argv[2];
|
|||
var curl = new Curl();
|
||||
|
||||
if (!url)
|
||||
url = 'www.yahoo.com';
|
||||
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;
|
||||
p("receive " + chunk.length)
|
||||
return chunk.length;
|
||||
});
|
||||
|
||||
curl.on('error', function(e) {
|
||||
curl.close();
|
||||
p("error: " + e.message)
|
||||
curl.close();
|
||||
});
|
||||
|
||||
|
||||
curl.on('end', function() {
|
||||
curl.close();
|
||||
p('done.')
|
||||
curl.close();
|
||||
});
|
||||
|
||||
curl.perform();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue