diff --git a/server.js b/server.js index 52b8dbb..e84c2f6 100644 --- a/server.js +++ b/server.js @@ -34,10 +34,18 @@ function getUrl (req, res) { logger.info('>> getting url'); function urlQuery (callback) { try { + let count = 0; http.request(options, (response) => { console.log(`STATUS: ${response.statusCode}`); console.log(`HEADERS: ${JSON.stringify(response.headers)}`); response.setEncoding('utf8'); + if (response.statusCode === 302) { + body = []; + logger.debug('>. follow', response.headers.location, count); + count++; + request(response.headers.location); + } + let data = ''; response.on('data', chunk => { data += chunk; @@ -50,7 +58,7 @@ function getUrl (req, res) { }); }).end(); - /*http.request(options).on('response', response => { + /* http.request(options).on('response', response => { let data = ''; response.on('data', chunk => { data += chunk;