Skip to content

Commit 9ec4aee

Browse files
author
Matt Allwood
committed
feat(MongoBinaryDownload): follow redirects
Add follow-redirects library to handle 302 redirects on fastdl.mongodb.org re: #785
1 parent 5fd9fd9 commit 9ec4aee

File tree

2 files changed

+7
-5
lines changed

2 files changed

+7
-5
lines changed

packages/mongodb-memory-server-core/package.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
"devDependencies": {
3434
"@types/debug": "^4.1.8",
3535
"@types/find-cache-dir": "^3.2.1",
36+
"@types/follow-redirects": "^1.14.1",
3637
"@types/semver": "^7.5.0",
3738
"@types/tar-stream": "^2.2.2",
3839
"@types/uuid": "^9.0.2",
@@ -46,6 +47,7 @@
4647
"camelcase": "^6.3.0",
4748
"debug": "^4.3.4",
4849
"find-cache-dir": "^3.3.2",
50+
"follow-redirects": "^1.15.2",
4951
"get-port": "^5.1.1",
5052
"https-proxy-agent": "^5.0.1",
5153
"md5-file": "^5.0.0",
@@ -68,6 +70,5 @@
6870
"test": "yarn run lint && yarn run coverage",
6971
"test:watch": "yarn run watch",
7072
"tscheck": "tsc --noEmit"
71-
},
72-
"optionalDependencies": {}
73+
}
7374
}

packages/mongodb-memory-server-core/src/util/MongoBinaryDownload.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { URL } from 'url';
33
import path from 'path';
44
import { promises as fspromises, createWriteStream, createReadStream, constants } from 'fs';
55
import md5File from 'md5-file';
6-
import https from 'https';
6+
import { https } from 'follow-redirects';
77
import { createUnzip } from 'zlib';
88
import tar from 'tar-stream';
99
import yauzl from 'yauzl';
@@ -16,6 +16,7 @@ import { DryMongoBinary } from './DryMongoBinary';
1616
import { MongoBinaryOpts } from './MongoBinary';
1717
import { clearLine } from 'readline';
1818
import { DownloadError, GenericMMSError, Md5CheckFailedError } from './errors';
19+
import { RequestOptions } from 'https';
1920

2021
const log = debug('MongoMS:MongoBinaryDownload');
2122

@@ -234,7 +235,7 @@ export class MongoBinaryDownload {
234235
const urlObject = new URL(downloadUrl);
235236
urlObject.port = urlObject.port || '443';
236237

237-
const requestOptions: https.RequestOptions = {
238+
const requestOptions: RequestOptions = {
238239
method: 'GET',
239240
rejectUnauthorized: strictSsl,
240241
protocol: envToBool(resolveConfig(ResolveConfigVariables.USE_HTTP)) ? 'http:' : 'https:',
@@ -402,7 +403,7 @@ export class MongoBinaryDownload {
402403
*/
403404
async httpDownload(
404405
url: URL,
405-
httpOptions: https.RequestOptions,
406+
httpOptions: RequestOptions,
406407
downloadLocation: string,
407408
tempDownloadLocation: string
408409
): Promise<string> {

0 commit comments

Comments
 (0)