Keep quick-start.js simple.
This commit is contained in:
parent
d138705419
commit
829db634a0
1 changed files with 26 additions and 30 deletions
|
@ -1,32 +1,28 @@
|
||||||
Curl = require('../index');
|
curl = require('../index');
|
||||||
options = {CONNECTTIMEOUT: 2};
|
|
||||||
keys = ["EFFECTIVE_URL", "CONTENT_TYPE", "PRIVATE", "FTP_ENTRY_PATH", "REDIRECT_URL", "PRIMARY_IP", "RTSP_SESSION_ID", "LOCAL_IP"]
|
// second argument 'options' is omitted.
|
||||||
curl = Curl.create(options)
|
url = 'www.google.com';
|
||||||
url = 'www.nodejs.org';
|
console.info("GET " + url);
|
||||||
curl(url, function(err) {
|
curl('www.google.com', function(err) {
|
||||||
self = this
|
console.info("\x1b[32mGet " + this.url + " finished.\x1b[0m");
|
||||||
keys.forEach(function(key) {
|
console.info("\tstatus: " + this.status);
|
||||||
console.info("\x1b[33m" + key + ": [" + self.info(key) + "]\x1b[0m");
|
console.info("\tbody length: " + this.body.length);
|
||||||
})
|
console.info("\tinfo SIZE_DOWNLOAD: " + this.info('SIZE_DOWNLOAD'));
|
||||||
console.info("body length: " + this.body.length);
|
console.info("\tinfo EFFECTIVE_URL " + this.info('EFFECTIVE_URL'));
|
||||||
this.close()
|
this.close();
|
||||||
});
|
});
|
||||||
curl = Curl.create(options)
|
|
||||||
url = 'www.yahoo.com'
|
// because we uses curl in parallel. and each curl is only for one session.
|
||||||
curl(url, function(err) {
|
// so use curl.create(defaultOptions = {}) to create new curl/session.
|
||||||
self = this
|
curl2 = curl.create({RAW: 1});
|
||||||
keys.forEach(function(key) {
|
url2 = 'www.google.com';
|
||||||
console.info("\x1b[33m" + key + ": [" + self.info(key) + "]\x1b[0m");
|
options2 = {FOLLOWLOCATION: 1};
|
||||||
})
|
console.info("GET " + url + " with default options " + JSON.stringify(curl2.defaultOptions) + ' and options ' + JSON.stringify(options2));
|
||||||
console.info("body length: " + this.body.length);
|
curl2(url2, options2, function(err) {
|
||||||
this.close()
|
console.info("\x1b[32mGet " + this.url + " with " + JSON.stringify(this.effective_options) + " finished.\x1b[0m");
|
||||||
});
|
console.info("\tstatus: " + this.status);
|
||||||
curl = Curl.create(options)
|
console.info("\tbody length: " + this.body.length);
|
||||||
curl('https://www.google.com', {VERBOSE: 1, RAW: 1}, function(err) {
|
console.info("\tinfo SIZE_DOWNLOAD: " + this.info('SIZE_DOWNLOAD'));
|
||||||
self = this
|
console.info("\tinfo EFFECTIVE_URL " + this.info('EFFECTIVE_URL'));
|
||||||
keys.forEach(function(key) {
|
this.close();
|
||||||
console.info("\x1b[33m" + key + ": [" + self.info(key) + "]\x1b[0m");
|
|
||||||
})
|
|
||||||
console.info("body length: " + this.body.length);
|
|
||||||
this.close()
|
|
||||||
});
|
});
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue