Skip to content

Commit 6c71fe2

Browse files
feat: expose request object before sending (#54)
* Update index.ts * Update index.ts * Update index.ts
1 parent 1106848 commit 6c71fe2

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

src/index.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import { PassThrough, Transform } from 'stream';
88

99
const httpLibs: {
1010
[key: string]: {
11-
get: (options: RequestOptions | string | URL, callback?: (res: IncomingMessage) => void) => ClientRequest;
11+
request: (options: RequestOptions | string | URL, callback?: (res: IncomingMessage) => void) => ClientRequest;
1212
};
1313
} = { 'http:': http, 'https:': https };
1414
const redirectStatusCodes = new Set([301, 302, 303, 307, 308]);
@@ -209,7 +209,7 @@ function Miniget(url: string, options: Miniget.Options = {}): Miniget.Stream {
209209
}
210210
};
211211

212-
activeRequest = httpLib.get(parsed, (res: IncomingMessage) => {
212+
activeRequest = httpLib.request(parsed, (res: IncomingMessage) => {
213213
// Needed for node v10, v12.
214214
// istanbul ignore next
215215
if (stream.destroyed) { return; }
@@ -270,6 +270,7 @@ function Miniget(url: string, options: Miniget.Options = {}): Miniget.Stream {
270270
streamDestroy(destroyErr);
271271
}
272272
stream.emit('request', activeRequest);
273+
activeRequest.end();
273274
};
274275

275276
stream.abort = (err?: Error) => {

0 commit comments

Comments
 (0)