Update low level Curl help.
This commit is contained in:
parent
2884985e9a
commit
e25785eb3f
1 changed files with 51 additions and 0 deletions
51
README.md
51
README.md
|
@ -104,3 +104,54 @@ Infos
|
|||
|
||||
slist will be returns in Array
|
||||
eg: CURLINFO_COOKIELIST
|
||||
|
||||
Low Level Curl Usage
|
||||
--------------------
|
||||
|
||||
require 'node-curl/lib/Curl'
|
||||
|
||||
Methods:
|
||||
|
||||
Curl setopt(optionName, optionValue)
|
||||
Curl perform()
|
||||
Curl on(eventType, callback)
|
||||
|
||||
Events:
|
||||
|
||||
'data', function(Buffer chunk) {}
|
||||
'error', function(Error error) {}
|
||||
'end', function() {}
|
||||
|
||||
Example: examples/low-level.js
|
||||
|
||||
var Curl = require('node-curl/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) {
|
||||
p("receive " + chunk.length)
|
||||
return chunk.length;
|
||||
});
|
||||
|
||||
curl.on('error', function(e) {
|
||||
p("error: " + e.message)
|
||||
curl.close();
|
||||
});
|
||||
|
||||
|
||||
curl.on('end', function() {
|
||||
p('done.')
|
||||
curl.close();
|
||||
});
|
||||
|
||||
curl.perform();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue