fixes #2 CookieList returning same data for each cookie
new structure for node-curl
This commit is contained in:
parent
e791a14c6e
commit
90f3135c8c
11 changed files with 461 additions and 237 deletions
|
@ -1,6 +1,6 @@
|
|||
// Generated by ToffeeScript 1.2.0-0
|
||||
// Generated by ToffeeScript 1.3.3
|
||||
(function() {
|
||||
var curl, fs, p, url, util,
|
||||
var cookieFile, curl, fs, options, p, util,
|
||||
_this = this;
|
||||
|
||||
curl = require('../index');
|
||||
|
@ -11,29 +11,42 @@
|
|||
|
||||
p = console.info;
|
||||
|
||||
url = 'www.google.com';
|
||||
cookieFile = 'node-curl-cookie.txt';
|
||||
|
||||
curl(url, {
|
||||
HTTPHEADER: 'BAR',
|
||||
options = {
|
||||
VERBOSE: 1,
|
||||
COOKIEFILE: 'node-curl-cookie.txt'
|
||||
}, function(_$$_err, _$$_res) {
|
||||
var err, res;
|
||||
COOKIEFILE: cookieFile,
|
||||
COOKIEJAR: cookieFile,
|
||||
ACCEPT_ENCODING: 'gzip',
|
||||
RAW: 1
|
||||
};
|
||||
|
||||
curl.debug = 1;
|
||||
|
||||
curl.setDefaultOptions(options);
|
||||
|
||||
curl('www.google.com', function(_$$_err) {
|
||||
var err;
|
||||
err = _$$_err;
|
||||
res = _$$_res;
|
||||
p("\x1b[33m" + util.inspect(res.info('COOKIELIST')) + "\x1b[0m");
|
||||
url = 'www.yahoo.com';
|
||||
return curl(url, {
|
||||
HTTPHEADER: ['foo', 'bar'],
|
||||
VERBOSE: 1,
|
||||
COOKIEFILE: 'node-curl-cookie.txt',
|
||||
RAW: 1
|
||||
}, function(_$$_err, _$$_res) {
|
||||
p("\x1b[33m" + util.inspect(curl.info('COOKIELIST')) + "\x1b[0m");
|
||||
curl.reset();
|
||||
return curl('www.yahoo.com', function(_$$_err) {
|
||||
var stream;
|
||||
err = _$$_err;
|
||||
res = _$$_res;
|
||||
p("\x1b[33m" + util.inspect(res.info('COOKIELIST')) + "\x1b[0m");
|
||||
p(res.body);
|
||||
return fs.unlink('node-curl-cookie.txt');
|
||||
p("\x1b[33m" + util.inspect(curl.info('COOKIELIST')) + "\x1b[0m");
|
||||
p("body length " + curl.body.length);
|
||||
p("\x1b[33mText in " + cookieFile + "\x1b[0m");
|
||||
p("----");
|
||||
stream = fs.createReadStream(cookieFile);
|
||||
stream.pipe(process.stdout);
|
||||
return stream.on('end', function() {
|
||||
var _this = this;
|
||||
p("----");
|
||||
p("deleting " + cookieFile);
|
||||
return fs.unlink(cookieFile, function() {
|
||||
return p("done.");
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue