mirror of
https://github.com/musix-org/musix-oss
synced 2024-12-23 22:33:17 +00:00
24 lines
538 B
JavaScript
24 lines
538 B
JavaScript
|
var needle = require('./..');
|
||
|
|
||
|
var resp = needle.get('google.com', { follow_max: 10, timeout: 5000 });
|
||
|
|
||
|
resp.on('readable', function() {
|
||
|
var chunk;
|
||
|
while (chunk = this.read()) {
|
||
|
console.log('Got ' + chunk.length + ' bytes');
|
||
|
}
|
||
|
})
|
||
|
|
||
|
resp.on('headers', function(headers) {
|
||
|
console.log('Got headers', headers);
|
||
|
})
|
||
|
|
||
|
resp.on('redirect', function(url) {
|
||
|
console.log('Redirected to url ' + url);
|
||
|
})
|
||
|
|
||
|
resp.on('done', function(err) {
|
||
|
console.log('Finished. No more data to receive.');
|
||
|
if (err) console.log('With error', err)
|
||
|
})
|