update
This commit is contained in:
parent
5729fd3650
commit
a877c92e53
10
server.js
10
server.js
@ -34,10 +34,18 @@ function getUrl (req, res) {
|
|||||||
logger.info('>> getting url');
|
logger.info('>> getting url');
|
||||||
function urlQuery (callback) {
|
function urlQuery (callback) {
|
||||||
try {
|
try {
|
||||||
|
let count = 0;
|
||||||
http.request(options, (response) => {
|
http.request(options, (response) => {
|
||||||
console.log(`STATUS: ${response.statusCode}`);
|
console.log(`STATUS: ${response.statusCode}`);
|
||||||
console.log(`HEADERS: ${JSON.stringify(response.headers)}`);
|
console.log(`HEADERS: ${JSON.stringify(response.headers)}`);
|
||||||
response.setEncoding('utf8');
|
response.setEncoding('utf8');
|
||||||
|
if (response.statusCode === 302) {
|
||||||
|
body = [];
|
||||||
|
logger.debug('>. follow', response.headers.location, count);
|
||||||
|
count++;
|
||||||
|
request(response.headers.location);
|
||||||
|
}
|
||||||
|
|
||||||
let data = '';
|
let data = '';
|
||||||
response.on('data', chunk => {
|
response.on('data', chunk => {
|
||||||
data += chunk;
|
data += chunk;
|
||||||
@ -50,7 +58,7 @@ function getUrl (req, res) {
|
|||||||
});
|
});
|
||||||
}).end();
|
}).end();
|
||||||
|
|
||||||
/*http.request(options).on('response', response => {
|
/* http.request(options).on('response', response => {
|
||||||
let data = '';
|
let data = '';
|
||||||
response.on('data', chunk => {
|
response.on('data', chunk => {
|
||||||
data += chunk;
|
data += chunk;
|
||||||
|
Loading…
Reference in New Issue
Block a user