Update README.
This commit is contained in:
parent
f02c0a6fbf
commit
05b8345650
2 changed files with 25 additions and 8 deletions
18
README.md
18
README.md
|
@ -17,7 +17,6 @@ Quick Start
|
|||
console.info(this.info('SIZE_DOWNLOAD'));
|
||||
});
|
||||
|
||||
|
||||
* with options
|
||||
|
||||
curl = require('node-curl')
|
||||
|
@ -43,6 +42,7 @@ Usage
|
|||
members:
|
||||
status - Http Response code
|
||||
body - Http body
|
||||
header - Http header
|
||||
|
||||
url - the url set by curl(...)
|
||||
options - the options set by curl(...)
|
||||
|
@ -52,6 +52,10 @@ Usage
|
|||
methods:
|
||||
info(name) - Get information of result, see 'info' section
|
||||
|
||||
REMARK:
|
||||
If the http is redirected, then header will contain at least 2 http headers.
|
||||
|
||||
|
||||
* Curl Control
|
||||
|
||||
members
|
||||
|
@ -139,6 +143,7 @@ Methods:
|
|||
Events:
|
||||
|
||||
'data', function(Buffer chunk) {}
|
||||
'header', function(Buffer chunk) {}
|
||||
'error', function(Error error) {}
|
||||
'end', function() {}
|
||||
|
||||
|
@ -159,21 +164,26 @@ Example: examples/low-level.js
|
|||
|
||||
// on 'data' must be returns chunk.length, or means interrupt the transfer
|
||||
curl.on('data', function(chunk) {
|
||||
p("receive " + chunk.length)
|
||||
p("receive " + chunk.length);
|
||||
return chunk.length;
|
||||
});
|
||||
|
||||
curl.on('header', function(chunk) {
|
||||
p("receive header " + chunk.length);
|
||||
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)
|
||||
p("error: " + e.message);
|
||||
curl.close();
|
||||
});
|
||||
|
||||
|
||||
curl.on('end', function() {
|
||||
p('code: ' + curl.getinfo('RESPONSE_CODE'));
|
||||
p('done.')
|
||||
p('done.');
|
||||
curl.close();
|
||||
});
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
var Curl = require('../lib/Curl')
|
||||
var Curl = require('../lib/Curl');
|
||||
|
||||
var p = console.log;
|
||||
var url = process.argv[2];
|
||||
|
@ -14,10 +14,17 @@ curl.setopt('VERBOSE', 1);
|
|||
|
||||
// on 'data' must be returns chunk.length, or means interrupt the transfer
|
||||
curl.on('data', function(chunk) {
|
||||
p("receive " + chunk.length)
|
||||
p("receive " + chunk.length);
|
||||
return chunk.length;
|
||||
});
|
||||
|
||||
curl.on('header', function(chunk) {
|
||||
p("receive header " + chunk.length);
|
||||
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();
|
||||
|
@ -25,9 +32,9 @@ curl.on('error', function(e) {
|
|||
|
||||
|
||||
curl.on('end', function() {
|
||||
p("code: " + curl.getinfo('RESPONSE_CODE'));
|
||||
curl.close();
|
||||
p('code: ' + curl.getinfo('RESPONSE_CODE'));
|
||||
p('done.');
|
||||
curl.close();
|
||||
});
|
||||
|
||||
curl.perform();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue