This commit is contained in:
Martin Donnelly 2017-09-11 11:52:17 +01:00
parent 5729fd3650
commit a877c92e53

View File

@ -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;