Skip to content

Commit bf39d2c

Browse files
huturensindresorhus
andauthoredJan 9, 2022
Fix nock compatibility (#1959)
Co-authored-by: Sindre Sorhus <sindresorhus@gmail.com>
1 parent 236e744 commit bf39d2c

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed
 

‎source/core/options.ts

+5-4
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,9 @@ import {Buffer} from 'node:buffer';
33
import {promisify, inspect} from 'node:util';
44
import {URL, URLSearchParams} from 'node:url';
55
import {checkServerIdentity} from 'node:tls';
6-
import {request as httpRequest} from 'node:http';
7-
import {request as httpsRequest} from 'node:https';
6+
// DO NOT use destructuring for `https.request` and `http.request` as it's not compatible with `nock`.
7+
import http from 'node:http';
8+
import https from 'node:https';
89
import type {Readable} from 'node:stream';
910
import type {Socket} from 'node:net';
1011
import type {SecureContextOptions, DetailedPeerCertificate} from 'node:tls';
@@ -2447,10 +2448,10 @@ export default class Options {
24472448
return http2wrapper.auto as RequestFunction;
24482449
}
24492450

2450-
return httpsRequest;
2451+
return https.request;
24512452
}
24522453

2453-
return httpRequest;
2454+
return http.request;
24542455
}
24552456

24562457
freeze() {

0 commit comments

Comments
 (0)
Please sign in to comment.