Last change
on this file since 188ee53 was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago |
initial commit
|
-
Property mode
set to
100644
|
File size:
538 bytes
|
Rev | Line | |
---|
[6a3a178] | 1 | var needle = require('./..');
|
---|
| 2 |
|
---|
| 3 | var resp = needle.get('google.com', { follow_max: 10, timeout: 5000 });
|
---|
| 4 |
|
---|
| 5 | resp.on('readable', function() {
|
---|
| 6 | var chunk;
|
---|
| 7 | while (chunk = this.read()) {
|
---|
| 8 | console.log('Got ' + chunk.length + ' bytes');
|
---|
| 9 | }
|
---|
| 10 | })
|
---|
| 11 |
|
---|
| 12 | resp.on('headers', function(headers) {
|
---|
| 13 | console.log('Got headers', headers);
|
---|
| 14 | })
|
---|
| 15 |
|
---|
| 16 | resp.on('redirect', function(url) {
|
---|
| 17 | console.log('Redirected to url ' + url);
|
---|
| 18 | })
|
---|
| 19 |
|
---|
| 20 | resp.on('done', function(err) {
|
---|
| 21 | console.log('Finished. No more data to receive.');
|
---|
| 22 | if (err) console.log('With error', err)
|
---|
| 23 | })
|
---|
Note:
See
TracBrowser
for help on using the repository browser.