Skip to content

Commit

Permalink
feat: follow 302 redirect
Browse files Browse the repository at this point in the history
  • Loading branch information
msimerson committed Mar 5, 2024
1 parent 8765f06 commit 3beba9a
Showing 1 changed file with 12 additions and 5 deletions.
17 changes: 12 additions & 5 deletions lib/mm-geolite-mirror.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
'use strict';

const fs = require('fs');
const https = require('https');
const path = require('path');
const url = require('url');
const zlib = require('zlib');
const fs = require('node:fs');
const https = require('node:https');
const path = require('node:path');
const url = require('node:url');
const zlib = require('node:zlib');

const config = require('../lib/config');
const con = require('../lib/console');
Expand Down Expand Up @@ -100,6 +100,13 @@ function expandTarball (dest, res, callback) {
function download (dest, opts, done) {

const request = https.request(opts, (res) => {

if (res.statusCode === 302) {
download(res.headers.location, opts, done)
request.end()
return
}

if (res.statusCode !== 200) {
con.error(`HEADERS: ${JSON.stringify(res.headers)}`);
return done(`response code ${res.statusCode} not handled!`);
Expand Down

0 comments on commit 3beba9a

Please sign in to comment.