Skip to content

Commit

Permalink
feat(MongoBinaryDownload): follow redirects
Browse files Browse the repository at this point in the history
Add follow-redirects library to handle 302 redirects on fastdl.mongodb.org

re: #785
  • Loading branch information
Matt Allwood committed Aug 2, 2023
1 parent 5fd9fd9 commit 9ec4aee
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
5 changes: 3 additions & 2 deletions packages/mongodb-memory-server-core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
"devDependencies": {
"@types/debug": "^4.1.8",
"@types/find-cache-dir": "^3.2.1",
"@types/follow-redirects": "^1.14.1",
"@types/semver": "^7.5.0",
"@types/tar-stream": "^2.2.2",
"@types/uuid": "^9.0.2",
Expand All @@ -46,6 +47,7 @@
"camelcase": "^6.3.0",
"debug": "^4.3.4",
"find-cache-dir": "^3.3.2",
"follow-redirects": "^1.15.2",
"get-port": "^5.1.1",
"https-proxy-agent": "^5.0.1",
"md5-file": "^5.0.0",
Expand All @@ -68,6 +70,5 @@
"test": "yarn run lint && yarn run coverage",
"test:watch": "yarn run watch",
"tscheck": "tsc --noEmit"
},
"optionalDependencies": {}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { URL } from 'url';
import path from 'path';
import { promises as fspromises, createWriteStream, createReadStream, constants } from 'fs';
import md5File from 'md5-file';
import https from 'https';
import { https } from 'follow-redirects';
import { createUnzip } from 'zlib';
import tar from 'tar-stream';
import yauzl from 'yauzl';
Expand All @@ -16,6 +16,7 @@ import { DryMongoBinary } from './DryMongoBinary';
import { MongoBinaryOpts } from './MongoBinary';
import { clearLine } from 'readline';
import { DownloadError, GenericMMSError, Md5CheckFailedError } from './errors';
import { RequestOptions } from 'https';

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

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

const requestOptions: https.RequestOptions = {
const requestOptions: RequestOptions = {
method: 'GET',
rejectUnauthorized: strictSsl,
protocol: envToBool(resolveConfig(ResolveConfigVariables.USE_HTTP)) ? 'http:' : 'https:',
Expand Down Expand Up @@ -402,7 +403,7 @@ export class MongoBinaryDownload {
*/
async httpDownload(
url: URL,
httpOptions: https.RequestOptions,
httpOptions: RequestOptions,
downloadLocation: string,
tempDownloadLocation: string
): Promise<string> {
Expand Down

0 comments on commit 9ec4aee

Please sign in to comment.