From 648e170fa83ac02c39554d716416c479e7d9ac38 Mon Sep 17 00:00:00 2001 From: Miao Jiang Date: Wed, 20 Feb 2013 03:30:36 +0800 Subject: [PATCH] Update README --- README.md | 4 +++- examples/low-level.js | 3 ++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index bc7179e..05574e4 100644 --- a/README.md +++ b/README.md @@ -144,6 +144,8 @@ Example: examples/low-level.js return chunk.length; }); + // curl.close() should be called in event 'error' and 'end' if the curl won't use any more. + // or the resource will not release until V8 garbage mark sweep. curl.on('error', function(e) { p("error: " + e.message) curl.close(); @@ -151,8 +153,8 @@ Example: examples/low-level.js curl.on('end', function() { - p('done.') p('code: ' + curl.getinfo('RESPONSE_CODE')); + p('done.') curl.close(); }); diff --git a/examples/low-level.js b/examples/low-level.js index b5df695..bc72d60 100644 --- a/examples/low-level.js +++ b/examples/low-level.js @@ -10,6 +10,7 @@ if (!url) curl.setopt('URL', url); curl.setopt('CONNECTTIMEOUT', 2); +curl.setopt('VERBOSE', 1); // on 'data' must be returns chunk.length, or means interrupt the transfer curl.on('data', function(chunk) { @@ -25,7 +26,7 @@ curl.on('error', function(e) { curl.on('end', function() { - curl.getinfo('RESPONSE_CODE'); + p("code: " + curl.getinfo('RESPONSE_CODE')); curl.close(); p('done.'); });