@mswjs/interceptors 0.15.2 → 0.15.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +49 -68
- package/lib/createInterceptor.d.ts +54 -0
- package/lib/createInterceptor.js +27 -0
- package/lib/createInterceptor.js.map +1 -0
- package/lib/index.d.ts +2 -2
- package/lib/index.js +2 -2
- package/lib/index.js.map +1 -1
- package/lib/interceptors/ClientRequest/NodeClientRequest.d.ts +5 -5
- package/lib/interceptors/ClientRequest/NodeClientRequest.js +15 -56
- package/lib/interceptors/ClientRequest/NodeClientRequest.js.map +1 -1
- package/lib/interceptors/ClientRequest/http.get.d.ts +3 -2
- package/lib/interceptors/ClientRequest/http.get.js +5 -2
- package/lib/interceptors/ClientRequest/http.get.js.map +1 -1
- package/lib/interceptors/ClientRequest/http.request.d.ts +3 -2
- package/lib/interceptors/ClientRequest/http.request.js +6 -3
- package/lib/interceptors/ClientRequest/http.request.js.map +1 -1
- package/lib/interceptors/ClientRequest/index.d.ts +4 -14
- package/lib/interceptors/ClientRequest/index.js +46 -59
- package/lib/interceptors/ClientRequest/index.js.map +1 -1
- package/lib/interceptors/ClientRequest/utils/getIncomingMessageBody.js +2 -7
- package/lib/interceptors/ClientRequest/utils/getIncomingMessageBody.js.map +1 -1
- package/lib/interceptors/XMLHttpRequest/XMLHttpRequestOverride.d.ts +4 -11
- package/lib/interceptors/XMLHttpRequest/XMLHttpRequestOverride.js +58 -110
- package/lib/interceptors/XMLHttpRequest/XMLHttpRequestOverride.js.map +1 -1
- package/lib/interceptors/XMLHttpRequest/index.d.ts +5 -11
- package/lib/interceptors/XMLHttpRequest/index.js +25 -43
- package/lib/interceptors/XMLHttpRequest/index.js.map +1 -1
- package/lib/interceptors/fetch/index.d.ts +2 -8
- package/lib/interceptors/fetch/index.js +68 -120
- package/lib/interceptors/fetch/index.js.map +1 -1
- package/lib/presets/browser.d.ts +1 -3
- package/lib/presets/browser.js +2 -2
- package/lib/presets/browser.js.map +1 -1
- package/lib/presets/node.d.ts +1 -3
- package/lib/presets/node.js +1 -1
- package/lib/presets/node.js.map +1 -1
- package/lib/remote.d.ts +21 -0
- package/lib/remote.js +178 -0
- package/lib/remote.js.map +1 -0
- package/lib/utils/toIsoResponse.d.ts +1 -1
- package/package.json +6 -6
- package/src/createInterceptor.ts +100 -0
- package/src/index.ts +2 -2
- package/src/interceptors/ClientRequest/NodeClientRequest.test.ts +70 -87
- package/src/interceptors/ClientRequest/NodeClientRequest.ts +100 -139
- package/src/interceptors/ClientRequest/http.get.ts +11 -7
- package/src/interceptors/ClientRequest/http.request.ts +12 -8
- package/src/interceptors/ClientRequest/index.ts +46 -46
- package/src/interceptors/ClientRequest/utils/getIncomingMessageBody.test.ts +0 -9
- package/src/interceptors/ClientRequest/utils/getIncomingMessageBody.ts +2 -9
- package/src/interceptors/XMLHttpRequest/XMLHttpRequestOverride.ts +159 -215
- package/src/interceptors/XMLHttpRequest/index.ts +23 -41
- package/src/interceptors/fetch/index.ts +55 -81
- package/src/presets/browser.ts +3 -3
- package/src/presets/node.ts +3 -3
- package/src/remote.ts +174 -0
- package/src/utils/.DS_Store +0 -0
- package/src/utils/toIsoResponse.ts +1 -1
- package/LICENSE.md +0 -9
- package/lib/BatchInterceptor.d.ts +0 -18
- package/lib/BatchInterceptor.js +0 -79
- package/lib/BatchInterceptor.js.map +0 -1
- package/lib/Interceptor.d.ts +0 -49
- package/lib/Interceptor.js +0 -197
- package/lib/Interceptor.js.map +0 -1
- package/lib/RemoteInterceptor.d.ts +0 -24
- package/lib/RemoteInterceptor.js +0 -216
- package/lib/RemoteInterceptor.js.map +0 -1
- package/lib/glossary.d.ts +0 -32
- package/lib/glossary.js +0 -3
- package/lib/glossary.js.map +0 -1
- package/lib/utils/AsyncEventEmitter.d.ts +0 -29
- package/lib/utils/AsyncEventEmitter.js +0 -241
- package/lib/utils/AsyncEventEmitter.js.map +0 -1
- package/lib/utils/createLazyCallback.d.ts +0 -11
- package/lib/utils/createLazyCallback.js +0 -75
- package/lib/utils/createLazyCallback.js.map +0 -1
- package/lib/utils/nextTick.d.ts +0 -2
- package/lib/utils/nextTick.js +0 -16
- package/lib/utils/nextTick.js.map +0 -1
- package/src/BatchInterceptor.test.ts +0 -113
- package/src/BatchInterceptor.ts +0 -60
- package/src/Interceptor.test.ts +0 -166
- package/src/Interceptor.ts +0 -226
- package/src/RemoteInterceptor.ts +0 -176
- package/src/glossary.ts +0 -42
- package/src/interceptors/ClientRequest/index.test.ts +0 -43
- package/src/utils/AsyncEventEmitter.test.ts +0 -68
- package/src/utils/AsyncEventEmitter.ts +0 -171
- package/src/utils/createLazyCallback.ts +0 -49
- package/src/utils/nextTick.ts +0 -11
package/README.md
CHANGED
|
@@ -98,111 +98,101 @@ npm install @mswjs/interceptors
|
|
|
98
98
|
|
|
99
99
|
## API
|
|
100
100
|
|
|
101
|
-
###
|
|
101
|
+
### `createInterceptor(options: CreateInterceptorOptions)`
|
|
102
102
|
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
- `ClientRequestInterceptor`
|
|
106
|
-
- `XMLHttpRequestInterceptor`
|
|
107
|
-
- `FetchInterceptor`
|
|
108
|
-
|
|
109
|
-
All aforementioned interceptors implement the same HTTP request interception contract, meaning that they allow you to handle intercepted requests in the same way, regardless of the request origin (`http`/`XMLHttpRequest`/`fetch`).
|
|
110
|
-
|
|
111
|
-
To use multiple interceptors at once, consider [`BatchInterceptor`](#BatchInterceptor).
|
|
112
|
-
|
|
113
|
-
```js
|
|
114
|
-
import { ClientRequestInterceptor } from '@mswjs/interceptors/lib/interceptors/ClientRequest'
|
|
115
|
-
|
|
116
|
-
const interceptor = new ClientRequestInterceptor()
|
|
117
|
-
interceptor.on('request', (request) => {
|
|
118
|
-
// Introspect request or mock its response
|
|
119
|
-
// via "request.respondWith()".
|
|
120
|
-
})
|
|
121
|
-
```
|
|
122
|
-
|
|
123
|
-
### `BatchInterceptor`
|
|
124
|
-
|
|
125
|
-
Applies multiple request interceptors at the same time.
|
|
103
|
+
Enables request interception in the current process.
|
|
126
104
|
|
|
127
105
|
```js
|
|
128
|
-
import {
|
|
106
|
+
import { createInterceptor } from '@mswjs/interceptors'
|
|
129
107
|
import nodeInterceptors from '@mswjs/interceptors/lib/presets/node'
|
|
130
108
|
|
|
131
|
-
const interceptor =
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
// Inspect the intercepted "request".
|
|
137
|
-
// Optionally, return a mocked response.
|
|
109
|
+
const interceptor = createInterceptor({
|
|
110
|
+
modules: nodeInterceptors,
|
|
111
|
+
resolver(request, ref) {
|
|
112
|
+
// Optionally, return a mocked response.
|
|
113
|
+
},
|
|
138
114
|
})
|
|
139
115
|
```
|
|
140
116
|
|
|
141
117
|
> Using the `/presets/node` interceptors preset is the recommended way to ensure all requests get intercepted, regardless of their origin.
|
|
142
118
|
|
|
143
|
-
### `
|
|
119
|
+
### `createRemoteInterceptor(options: CreateRemoteInterceptorOptions)`
|
|
144
120
|
|
|
145
121
|
Enables request interception in the current process while delegating the response resolution logic to the _parent process_. **Requires the current process to be a child process**. Requires the parent process to establish a resolver by calling the `createRemoteResolver` function.
|
|
146
122
|
|
|
147
123
|
```js
|
|
148
|
-
|
|
149
|
-
import { RemoteHttpInterceptor } from '@mswjs/interceptors'
|
|
150
|
-
import { ClientRequestInterceptor } from '@mswjs/interceptors/lib/interceptors/ClientRequest'
|
|
124
|
+
import { createRemoteInterceptor } from '@mswjs/interceptors'
|
|
151
125
|
|
|
152
|
-
const interceptor =
|
|
153
|
-
|
|
154
|
-
interceptors: [new ClientRequestInterceptor()],
|
|
126
|
+
const interceptor = createRemoteInterceptor({
|
|
127
|
+
modules: nodeInterceptors,
|
|
155
128
|
})
|
|
156
129
|
|
|
157
130
|
interceptor.apply()
|
|
158
131
|
|
|
159
132
|
process.on('disconnect', () => {
|
|
160
|
-
interceptor.
|
|
133
|
+
interceptor.restore()
|
|
161
134
|
})
|
|
162
135
|
```
|
|
163
136
|
|
|
164
|
-
You can still listen to and handle any requests in the child process via the `request` event listener. Keep in mind that a single request can only be responded to once.
|
|
165
|
-
|
|
166
137
|
### `createRemoteResolver(options: CreateRemoteResolverOptions)`
|
|
167
138
|
|
|
168
139
|
Resolves an intercepted request in the given child `process`. Requires for that child process to enable request interception by calling the `createRemoteInterceptor` function.
|
|
169
140
|
|
|
170
141
|
```js
|
|
171
|
-
// parent.js
|
|
172
142
|
import { spawn } from 'child_process'
|
|
173
|
-
import {
|
|
143
|
+
import { createRemoteResolver } from '@mswjs/interceptors'
|
|
174
144
|
|
|
175
145
|
const appProcess = spawn('node', ['app.js'], {
|
|
176
146
|
stdio: ['inherit', 'inherit', 'inherit', 'ipc'],
|
|
177
147
|
})
|
|
178
148
|
|
|
179
|
-
|
|
149
|
+
createRemoteResolver({
|
|
180
150
|
process: appProcess,
|
|
151
|
+
resolver(request) {
|
|
152
|
+
// Optionally, return a mocked response
|
|
153
|
+
// for a request that occurred in the "appProcess".
|
|
154
|
+
},
|
|
181
155
|
})
|
|
156
|
+
```
|
|
157
|
+
|
|
158
|
+
### Interceptors
|
|
159
|
+
|
|
160
|
+
This library utilizes a concept of _interceptors_–functions that extend request modules, handle mocked responses, and restore themselves when done.
|
|
161
|
+
|
|
162
|
+
**Available interceptors:**
|
|
163
|
+
|
|
164
|
+
- `/interceptors/ClientRequest`
|
|
165
|
+
- `/interceptors/XMLHttpRequest`
|
|
166
|
+
- `/interceptors/fetch`
|
|
167
|
+
|
|
168
|
+
To use a single, or multiple interceptors, import and provide them to the `createInterceptor` function.
|
|
182
169
|
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
170
|
+
```js
|
|
171
|
+
import { createInterceptor } from '@mswjs/interceptors'
|
|
172
|
+
import { interceptXMLHttpRequest } from '@mswjs/interceptors/lib/interceptors/XMLHttpRequest'
|
|
173
|
+
|
|
174
|
+
// This `interceptor` instance would handle only XMLHttpRequest,
|
|
175
|
+
// ignoring requests issued via `http`/`https` modules.
|
|
176
|
+
const interceptor = createInterceptor({
|
|
177
|
+
modules: [interceptXMLHttpRequest],
|
|
186
178
|
})
|
|
187
179
|
```
|
|
188
180
|
|
|
181
|
+
> Interceptors are crucial in leveraging environment-specific module overrides. Certain environments (i.e. React Native) do not have access to native Node.js modules (like `http`). Importing such modules throws an exception and should be avoided.
|
|
182
|
+
|
|
189
183
|
### Methods
|
|
190
184
|
|
|
191
|
-
####
|
|
185
|
+
#### `.apply(): void`
|
|
192
186
|
|
|
193
|
-
Applies
|
|
187
|
+
Applies module patches and enables interception of the requests.
|
|
194
188
|
|
|
195
189
|
```js
|
|
196
190
|
interceptor.apply()
|
|
197
191
|
```
|
|
198
192
|
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
#### `on`
|
|
193
|
+
#### `.on(event, listener): boolean`
|
|
202
194
|
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
Each interceptor decides what event map to implement. Currently, all exported interceptors implement an HTTP request event map that consists of the following events:
|
|
195
|
+
Adds an event listener to one of the following supported events:
|
|
206
196
|
|
|
207
197
|
- `request`, signals when a new request happens;
|
|
208
198
|
- `response`, signals when a response was sent.
|
|
@@ -211,23 +201,14 @@ Each interceptor decides what event map to implement. Currently, all exported in
|
|
|
211
201
|
interceptor.on('request', (request) => {
|
|
212
202
|
console.log('[%s] %s', request.method, request.url.toString())
|
|
213
203
|
})
|
|
214
|
-
|
|
215
|
-
interceptor.on('response', (request, response) => {
|
|
216
|
-
console.log(
|
|
217
|
-
'Received response to [%s] %s:',
|
|
218
|
-
request.method,
|
|
219
|
-
request.url.href,
|
|
220
|
-
response
|
|
221
|
-
)
|
|
222
|
-
})
|
|
223
204
|
```
|
|
224
205
|
|
|
225
|
-
#### `
|
|
206
|
+
#### `.restore(): void`
|
|
226
207
|
|
|
227
|
-
|
|
208
|
+
Restores all extensions and stops the interception of future requests.
|
|
228
209
|
|
|
229
210
|
```js
|
|
230
|
-
interceptor.
|
|
211
|
+
interceptor.restore()
|
|
231
212
|
```
|
|
232
213
|
|
|
233
214
|
## Special mention
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
import { IncomingMessage } from 'http';
|
|
3
|
+
import { HeadersObject, Headers } from 'headers-polyfill';
|
|
4
|
+
import { StrictEventEmitter } from 'strict-event-emitter';
|
|
5
|
+
export declare type Interceptor = (observer: Observer, resolver: Resolver) => InterceptorCleanupFn;
|
|
6
|
+
export declare type Observer = StrictEventEmitter<InterceptorEventsMap>;
|
|
7
|
+
/**
|
|
8
|
+
* A side-effect function to restore all the patched modules.
|
|
9
|
+
*/
|
|
10
|
+
export declare type InterceptorCleanupFn = () => void;
|
|
11
|
+
export declare type RequestCredentials = 'omit' | 'include' | 'same-origin';
|
|
12
|
+
export interface IsomorphicRequest {
|
|
13
|
+
id: string;
|
|
14
|
+
url: URL;
|
|
15
|
+
method: string;
|
|
16
|
+
headers: Headers;
|
|
17
|
+
/**
|
|
18
|
+
* The value of the request client's "credentials" option
|
|
19
|
+
* or a compatible alternative (i.e. `withCredentials` for `XMLHttpRequest`).
|
|
20
|
+
* Always equals to "omit" in Node.js.
|
|
21
|
+
*/
|
|
22
|
+
credentials: RequestCredentials;
|
|
23
|
+
body?: string;
|
|
24
|
+
}
|
|
25
|
+
export interface IsomorphicResponse {
|
|
26
|
+
status: number;
|
|
27
|
+
statusText: string;
|
|
28
|
+
headers: Headers;
|
|
29
|
+
body?: string;
|
|
30
|
+
}
|
|
31
|
+
export interface MockedResponse extends Omit<Partial<IsomorphicResponse>, 'headers'> {
|
|
32
|
+
headers?: HeadersObject;
|
|
33
|
+
}
|
|
34
|
+
export interface InterceptorEventsMap {
|
|
35
|
+
request(request: IsomorphicRequest): void;
|
|
36
|
+
response(request: IsomorphicRequest, response: IsomorphicResponse): void;
|
|
37
|
+
}
|
|
38
|
+
export declare type Resolver = (request: IsomorphicRequest, ref: IncomingMessage | XMLHttpRequest | Request) => MockedResponse | Promise<MockedResponse | void> | void;
|
|
39
|
+
export interface InterceptorOptions {
|
|
40
|
+
modules: Interceptor[];
|
|
41
|
+
resolver: Resolver;
|
|
42
|
+
}
|
|
43
|
+
export interface InterceptorApi {
|
|
44
|
+
/**
|
|
45
|
+
* Apply necessary module patches to provision the interception of requests.
|
|
46
|
+
*/
|
|
47
|
+
apply(): void;
|
|
48
|
+
on<Event extends keyof InterceptorEventsMap>(event: Event, listener: InterceptorEventsMap[Event]): void;
|
|
49
|
+
/**
|
|
50
|
+
* Restore all applied module patches and disable the interception.
|
|
51
|
+
*/
|
|
52
|
+
restore(): void;
|
|
53
|
+
}
|
|
54
|
+
export declare function createInterceptor(options: InterceptorOptions): InterceptorApi;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.createInterceptor = void 0;
|
|
4
|
+
var strict_event_emitter_1 = require("strict-event-emitter");
|
|
5
|
+
function createInterceptor(options) {
|
|
6
|
+
var observer = new strict_event_emitter_1.StrictEventEmitter();
|
|
7
|
+
var cleanupFns = [];
|
|
8
|
+
return {
|
|
9
|
+
apply: function () {
|
|
10
|
+
cleanupFns = options.modules.map(function (interceptor) {
|
|
11
|
+
return interceptor(observer, options.resolver);
|
|
12
|
+
});
|
|
13
|
+
},
|
|
14
|
+
on: function (event, listener) {
|
|
15
|
+
observer.addListener(event, listener);
|
|
16
|
+
},
|
|
17
|
+
restore: function () {
|
|
18
|
+
observer.removeAllListeners();
|
|
19
|
+
if (cleanupFns.length === 0) {
|
|
20
|
+
throw new Error("Failed to restore patched modules: no patches found. Did you forget to run \".apply()\"?");
|
|
21
|
+
}
|
|
22
|
+
cleanupFns.forEach(function (restore) { return restore(); });
|
|
23
|
+
},
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
exports.createInterceptor = createInterceptor;
|
|
27
|
+
//# sourceMappingURL=createInterceptor.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"createInterceptor.js","sourceRoot":"","sources":["../src/createInterceptor.ts"],"names":[],"mappings":";;;AAEA,6DAAyD;AAwEzD,SAAgB,iBAAiB,CAAC,OAA2B;IAC3D,IAAM,QAAQ,GAAG,IAAI,yCAAkB,EAAwB,CAAA;IAC/D,IAAI,UAAU,GAA2B,EAAE,CAAA;IAE3C,OAAO;QACL,KAAK;YACH,UAAU,GAAG,OAAO,CAAC,OAAO,CAAC,GAAG,CAAC,UAAC,WAAW;gBAC3C,OAAO,WAAW,CAAC,QAAQ,EAAE,OAAO,CAAC,QAAQ,CAAC,CAAA;YAChD,CAAC,CAAC,CAAA;QACJ,CAAC;QACD,EAAE,YAAC,KAAK,EAAE,QAAQ;YAChB,QAAQ,CAAC,WAAW,CAAC,KAAK,EAAE,QAAQ,CAAC,CAAA;QACvC,CAAC;QACD,OAAO;YACL,QAAQ,CAAC,kBAAkB,EAAE,CAAA;YAE7B,IAAI,UAAU,CAAC,MAAM,KAAK,CAAC,EAAE;gBAC3B,MAAM,IAAI,KAAK,CACb,0FAAwF,CACzF,CAAA;aACF;YAED,UAAU,CAAC,OAAO,CAAC,UAAC,OAAO,IAAK,OAAA,OAAO,EAAE,EAAT,CAAS,CAAC,CAAA;QAC5C,CAAC;KACF,CAAA;AACH,CAAC;AAzBD,8CAyBC"}
|
package/lib/index.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export * from './
|
|
2
|
-
export * from './
|
|
1
|
+
export * from './createInterceptor';
|
|
2
|
+
export * from './remote';
|
|
3
3
|
export { getCleanUrl } from './utils/getCleanUrl';
|
package/lib/index.js
CHANGED
|
@@ -11,8 +11,8 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
11
11
|
};
|
|
12
12
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
13
|
exports.getCleanUrl = void 0;
|
|
14
|
-
__exportStar(require("./
|
|
15
|
-
__exportStar(require("./
|
|
14
|
+
__exportStar(require("./createInterceptor"), exports);
|
|
15
|
+
__exportStar(require("./remote"), exports);
|
|
16
16
|
/* Utils */
|
|
17
17
|
var getCleanUrl_1 = require("./utils/getCleanUrl");
|
|
18
18
|
Object.defineProperty(exports, "getCleanUrl", { enumerable: true, get: function () { return getCleanUrl_1.getCleanUrl; } });
|
package/lib/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;AAAA,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;AAAA,sDAAmC;AACnC,2CAAwB;AAExB,WAAW;AACX,mDAAiD;AAAxC,0GAAA,WAAW,OAAA"}
|
|
@@ -1,13 +1,12 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
|
-
import type { Debugger } from 'debug';
|
|
3
2
|
import { ClientRequest } from 'http';
|
|
4
|
-
import type {
|
|
3
|
+
import type { Observer, Resolver } from '../../createInterceptor';
|
|
5
4
|
import { NormalizedClientRequestArgs } from './utils/normalizeClientRequestArgs';
|
|
6
5
|
import { ClientRequestWriteArgs } from './utils/normalizeClientRequestWriteArgs';
|
|
7
6
|
export declare type Protocol = 'http' | 'https';
|
|
8
7
|
export interface NodeClientOptions {
|
|
9
|
-
|
|
10
|
-
|
|
8
|
+
observer: Observer;
|
|
9
|
+
resolver: Resolver;
|
|
11
10
|
}
|
|
12
11
|
export declare class NodeClientRequest extends ClientRequest {
|
|
13
12
|
/**
|
|
@@ -18,7 +17,8 @@ export declare class NodeClientRequest extends ClientRequest {
|
|
|
18
17
|
private url;
|
|
19
18
|
private options;
|
|
20
19
|
private response;
|
|
21
|
-
private
|
|
20
|
+
private resolver;
|
|
21
|
+
private observer;
|
|
22
22
|
private log;
|
|
23
23
|
private chunks;
|
|
24
24
|
private responseSource;
|
|
@@ -14,17 +14,6 @@ var __extends = (this && this.__extends) || (function () {
|
|
|
14
14
|
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
15
15
|
};
|
|
16
16
|
})();
|
|
17
|
-
var __assign = (this && this.__assign) || function () {
|
|
18
|
-
__assign = Object.assign || function(t) {
|
|
19
|
-
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
20
|
-
s = arguments[i];
|
|
21
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
22
|
-
t[p] = s[p];
|
|
23
|
-
}
|
|
24
|
-
return t;
|
|
25
|
-
};
|
|
26
|
-
return __assign.apply(this, arguments);
|
|
27
|
-
};
|
|
28
17
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
29
18
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
30
19
|
return new (P || (P = Promise))(function (resolve, reject) {
|
|
@@ -95,6 +84,7 @@ var __values = (this && this.__values) || function(o) {
|
|
|
95
84
|
};
|
|
96
85
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
97
86
|
exports.NodeClientRequest = void 0;
|
|
87
|
+
var debug_1 = require("debug");
|
|
98
88
|
var http_1 = require("http");
|
|
99
89
|
var until_1 = require("@open-draft/until");
|
|
100
90
|
var lib_1 = require("headers-polyfill/lib");
|
|
@@ -106,8 +96,6 @@ var getIncomingMessageBody_1 = require("./utils/getIncomingMessageBody");
|
|
|
106
96
|
var bodyBufferToString_1 = require("./utils/bodyBufferToString");
|
|
107
97
|
var normalizeClientRequestWriteArgs_1 = require("./utils/normalizeClientRequestWriteArgs");
|
|
108
98
|
var cloneIncomingMessage_1 = require("./utils/cloneIncomingMessage");
|
|
109
|
-
var createLazyCallback_1 = require("../../utils/createLazyCallback");
|
|
110
|
-
var outvariant_1 = require("outvariant");
|
|
111
99
|
var NodeClientRequest = /** @class */ (function (_super) {
|
|
112
100
|
__extends(NodeClientRequest, _super);
|
|
113
101
|
function NodeClientRequest(_a, options) {
|
|
@@ -116,7 +104,7 @@ var NodeClientRequest = /** @class */ (function (_super) {
|
|
|
116
104
|
_this.chunks = [];
|
|
117
105
|
_this.responseSource = 'mock';
|
|
118
106
|
_this.requestBody = [];
|
|
119
|
-
_this.log =
|
|
107
|
+
_this.log = debug_1.debug("http " + requestOptions.method + " " + url.href);
|
|
120
108
|
_this.log('constructing ClientRequest using options:', {
|
|
121
109
|
url: url,
|
|
122
110
|
requestOptions: requestOptions,
|
|
@@ -124,7 +112,8 @@ var NodeClientRequest = /** @class */ (function (_super) {
|
|
|
124
112
|
});
|
|
125
113
|
_this.url = url;
|
|
126
114
|
_this.options = requestOptions;
|
|
127
|
-
_this.
|
|
115
|
+
_this.resolver = options.resolver;
|
|
116
|
+
_this.observer = options.observer;
|
|
128
117
|
// Construct a mocked response message.
|
|
129
118
|
_this.response = new http_1.IncomingMessage(_this.socket);
|
|
130
119
|
return _this;
|
|
@@ -149,13 +138,9 @@ var NodeClientRequest = /** @class */ (function (_super) {
|
|
|
149
138
|
_this.log('request chunk successfully written!');
|
|
150
139
|
}
|
|
151
140
|
/**
|
|
152
|
-
*
|
|
141
|
+
* @todo Do not call callback if the `chunk` is empty.
|
|
153
142
|
* @see https://nodejs.org/api/http.html#requestwritechunk-encoding-callback
|
|
154
143
|
*/
|
|
155
|
-
if (!chunk || chunk.length === 0) {
|
|
156
|
-
_this.log('written chunk is empty, skipping callback...');
|
|
157
|
-
return;
|
|
158
|
-
}
|
|
159
144
|
_this.log('executing custom write callback:', callback);
|
|
160
145
|
callback === null || callback === void 0 ? void 0 : callback(error);
|
|
161
146
|
},
|
|
@@ -178,37 +163,16 @@ var NodeClientRequest = /** @class */ (function (_super) {
|
|
|
178
163
|
this.log('normalized arguments:', { chunk: chunk, encoding: encoding, callback: callback });
|
|
179
164
|
var requestBody = this.getRequestBody(chunk);
|
|
180
165
|
var isomorphicRequest = this.toIsomorphicRequest(requestBody);
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
maxCallsCallback: function () {
|
|
184
|
-
outvariant_1.invariant(false, 'Failed to respond to "%s %s" request: the "request" event has already been responded to.', isomorphicRequest.method, isomorphicRequest.url.href);
|
|
185
|
-
},
|
|
186
|
-
}) });
|
|
187
|
-
// Notify the interceptor about the request.
|
|
188
|
-
// This will call any "request" listeners the users have.
|
|
189
|
-
this.log('emitting the "request" event for %d listener(s)...', this.emitter.listenerCount('request'));
|
|
190
|
-
this.emitter.emit('request', interactiveIsomorphicRequest);
|
|
166
|
+
this.observer.emit('request', isomorphicRequest);
|
|
167
|
+
this.log('executing response resolver...');
|
|
191
168
|
// Execute the resolver Promise like a side-effect.
|
|
192
169
|
// Node.js 16 forces "ClientRequest.end" to be synchronous and return "this".
|
|
193
|
-
until_1.until(function () { return __awaiter(_this, void 0, void 0, function () {
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
switch (_b.label) {
|
|
197
|
-
case 0: return [4 /*yield*/, this.emitter.untilIdle('request')];
|
|
198
|
-
case 1:
|
|
199
|
-
_b.sent();
|
|
200
|
-
this.log('all request listeners have been resolved!');
|
|
201
|
-
return [4 /*yield*/, interactiveIsomorphicRequest.respondWith.invoked()];
|
|
202
|
-
case 2:
|
|
203
|
-
_a = __read.apply(void 0, [_b.sent(), 1]), mockedResponse = _a[0];
|
|
204
|
-
this.log('event.respondWith called with:', mockedResponse);
|
|
205
|
-
return [2 /*return*/, mockedResponse];
|
|
206
|
-
}
|
|
207
|
-
});
|
|
208
|
-
}); }).then(function (_a) {
|
|
170
|
+
until_1.until(function () { return __awaiter(_this, void 0, void 0, function () { return __generator(this, function (_a) {
|
|
171
|
+
return [2 /*return*/, this.resolver(isomorphicRequest, this.response)];
|
|
172
|
+
}); }); }).then(function (_a) {
|
|
209
173
|
var e_1, _b;
|
|
210
174
|
var _c = __read(_a, 2), resolverException = _c[0], mockedResponse = _c[1];
|
|
211
|
-
_this.log('
|
|
175
|
+
_this.log('resolver has finished');
|
|
212
176
|
// Halt the request whenever the resolver throws an exception.
|
|
213
177
|
if (resolverException) {
|
|
214
178
|
_this.log('encountered resolver exception, aborting request...', resolverException);
|
|
@@ -224,10 +188,10 @@ var NodeClientRequest = /** @class */ (function (_super) {
|
|
|
224
188
|
_this.log(isomorphicResponse.status, isomorphicResponse.statusText, isomorphicResponse.body, '(MOCKED)');
|
|
225
189
|
callback === null || callback === void 0 ? void 0 : callback();
|
|
226
190
|
_this.log('emitting the custom "response" event...');
|
|
227
|
-
_this.
|
|
191
|
+
_this.observer.emit('response', isomorphicRequest, isomorphicResponse);
|
|
228
192
|
return _this;
|
|
229
193
|
}
|
|
230
|
-
_this.log('no mocked response
|
|
194
|
+
_this.log('no mocked response found!');
|
|
231
195
|
// Set the response source to "bypass".
|
|
232
196
|
// Any errors emitted past this point are not suppressed.
|
|
233
197
|
_this.responseSource = 'bypass';
|
|
@@ -273,7 +237,7 @@ var NodeClientRequest = /** @class */ (function (_super) {
|
|
|
273
237
|
this.log(response.statusCode, response.statusMessage, responseBody);
|
|
274
238
|
this.log('original response headers:', response.headers);
|
|
275
239
|
this.log('emitting the custom "response" event...');
|
|
276
|
-
this.
|
|
240
|
+
this.observer.emit('response', isomorphicRequest, {
|
|
277
241
|
status: response.statusCode || 200,
|
|
278
242
|
statusText: response.statusMessage || 'OK',
|
|
279
243
|
headers: lib_1.objectToHeaders(response.headers),
|
|
@@ -450,12 +414,7 @@ var NodeClientRequest = /** @class */ (function (_super) {
|
|
|
450
414
|
* The list of internal Node.js errors to suppress while
|
|
451
415
|
* using the "mock" response source.
|
|
452
416
|
*/
|
|
453
|
-
NodeClientRequest.suppressErrorCodes = [
|
|
454
|
-
'ENOTFOUND',
|
|
455
|
-
'ECONNREFUSED',
|
|
456
|
-
'ECONNRESET',
|
|
457
|
-
'EAI_AGAIN',
|
|
458
|
-
];
|
|
417
|
+
NodeClientRequest.suppressErrorCodes = ['ENOTFOUND', 'ECONNREFUSED', 'ECONNRESET'];
|
|
459
418
|
return NodeClientRequest;
|
|
460
419
|
}(http_1.ClientRequest));
|
|
461
420
|
exports.NodeClientRequest = NodeClientRequest;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"NodeClientRequest.js","sourceRoot":"","sources":["../../../src/interceptors/ClientRequest/NodeClientRequest.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEA,6BAAqD;AACrD,2CAAyC;AACzC,4CAA+D;AAM/D,yCAAyC;AAEzC,mEAAiE;AACjE,uFAG8C;AAE9C,2DAAyD;AACzD,yEAAuE;AACvE,iEAA+D;AAC/D,2FAIgD;AAChD,qEAAmE;AACnE,qEAAmE;AACnE,yCAAsC;AAStC;IAAuC,qCAAa;IA2BlD,2BACE,EAA4D,EAC5D,OAA0B;YAD1B,KAAA,aAA4D,EAA3D,GAAG,QAAA,EAAE,cAAc,QAAA,EAAE,QAAQ,QAAA;QADhC,YAIE,kBAAM,cAAc,EAAE,QAAQ,CAAC,SAkBhC;QAhCO,YAAM,GAIT,EAAE,CAAA;QACC,oBAAc,GAAsB,MAAM,CAAA;QAG3C,iBAAW,GAAa,EAAE,CAAA;QAQ/B,KAAI,CAAC,GAAG,GAAG,OAAO,CAAC,GAAG,CAAC,MAAM,CAC3B,aAAW,cAAc,CAAC,MAAM,SAAI,GAAG,CAAC,IAAM,CAC/C,CAAA;QAED,KAAI,CAAC,GAAG,CAAC,2CAA2C,EAAE;YACpD,GAAG,KAAA;YACH,cAAc,gBAAA;YACd,QAAQ,UAAA;SACT,CAAC,CAAA;QAEF,KAAI,CAAC,GAAG,GAAG,GAAG,CAAA;QACd,KAAI,CAAC,OAAO,GAAG,cAAc,CAAA;QAC7B,KAAI,CAAC,OAAO,GAAG,OAAO,CAAC,OAAO,CAAA;QAE9B,uCAAuC;QACvC,KAAI,CAAC,QAAQ,GAAG,IAAI,sBAAe,CAAC,KAAI,CAAC,MAAO,CAAC,CAAA;;IACnD,CAAC;IAED,iCAAK,GAAL;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AG,IAAI,aAAO,EAAE,CAAA;;YAC7B,KAAwC,IAAA,KAAA,SAAA,MAAM,CAAC,OAAO,CAAC,eAAe,CAAC,CAAA,gBAAA,4BAAE;gBAA9D,IAAA,KAAA,mBAAyB,EAAxB,UAAU,QAAA,EAAE,WAAW,QAAA;gBACjC,IAAI,CAAC,WAAW,EAAE;oBAChB,SAAQ;iBACT;gBAED,OAAO,CAAC,GAAG,CAAC,UAAU,CAAC,WAAW,EAAE,EAAE,WAAW,CAAC,QAAQ,EAAE,CAAC,CAAA;aAC9D;;;;;;;;;QAED,IAAM,iBAAiB,GAAsB;YAC3C,EAAE,EAAE,aAAM,EAAE;YACZ,GAAG,EAAE,IAAI,CAAC,GAAG;YACb,MAAM,EAAE,IAAI,CAAC,OAAO,CAAC,MAAM,IAAI,KAAK;YACpC,WAAW,EAAE,aAAa;YAC1B,OAAO,SAAA;YACP,IAAI,MAAA;SACL,CAAA;QAED,IAAI,CAAC,GAAG,CAAC,0CAA0C,EAAE,iBAAiB,CAAC,CAAA;QACvE,OAAO,iBAAiB,CAAA;IAC1B,CAAC;IA3YD;;;OAGG;IACI,oCAAkB,GAAG;QAC1B,WAAW;QACX,cAAc;QACd,YAAY;QACZ,WAAW;KACZ,CAAA;IAmYH,wBAAC;CAAA,AA7YD,CAAuC,oBAAa,GA6YnD;AA7YY,8CAAiB"}
|
|
1
|
+
{"version":3,"file":"NodeClientRequest.js","sourceRoot":"","sources":["../../../src/interceptors/ClientRequest/NodeClientRequest.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,+BAAuC;AAEvC,6BAAqD;AACrD,2CAAyC;AACzC,4CAA+D;AAO/D,yCAAyC;AACzC,mEAAiE;AACjE,uFAG8C;AAE9C,2DAAyD;AACzD,yEAAuE;AACvE,iEAA+D;AAC/D,2FAIgD;AAChD,qEAAmE;AASnE;IAA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AAC,GAAG,CAAC,2BAA2B,EAAE,eAAe,CAAC,CAAA;QAEtD,IAAM,OAAO,GAAG,IAAI,aAAO,EAAE,CAAA;;YAC7B,KAAwC,IAAA,KAAA,SAAA,MAAM,CAAC,OAAO,CAAC,eAAe,CAAC,CAAA,gBAAA,4BAAE;gBAA9D,IAAA,KAAA,mBAAyB,EAAxB,UAAU,QAAA,EAAE,WAAW,QAAA;gBACjC,IAAI,CAAC,WAAW,EAAE;oBAChB,SAAQ;iBACT;gBAED,OAAO,CAAC,GAAG,CAAC,UAAU,CAAC,WAAW,EAAE,EAAE,WAAW,CAAC,QAAQ,EAAE,CAAC,CAAA;aAC9D;;;;;;;;;QAED,IAAM,iBAAiB,GAAsB;YAC3C,EAAE,EAAE,aAAM,EAAE;YACZ,GAAG,EAAE,IAAI,CAAC,GAAG;YACb,MAAM,EAAE,IAAI,CAAC,OAAO,CAAC,MAAM,IAAI,KAAK;YACpC,WAAW,EAAE,aAAa;YAC1B,OAAO,SAAA;YACP,IAAI,MAAA;SACL,CAAA;QAED,IAAI,CAAC,GAAG,CAAC,0CAA0C,EAAE,iBAAiB,CAAC,CAAA;QACvE,OAAO,iBAAiB,CAAA;IAC1B,CAAC;IAtWD;;;OAGG;IACI,oCAAkB,GAAG,CAAC,WAAW,EAAE,cAAc,EAAE,YAAY,CAAC,CAAA;IAmWzE,wBAAC;CAAA,AAxWD,CAAuC,oBAAa,GAwWnD;AAxWY,8CAAiB"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { ClientRequest } from 'node:http';
|
|
2
|
-
import {
|
|
2
|
+
import { Observer, Resolver } from '../../createInterceptor';
|
|
3
|
+
import { Protocol } from './NodeClientRequest';
|
|
3
4
|
import { ClientRequestArgs } from './utils/normalizeClientRequestArgs';
|
|
4
|
-
export declare function get(protocol: Protocol,
|
|
5
|
+
export declare function get(protocol: Protocol, resolver: Resolver, observer: Observer): (...args: ClientRequestArgs) => ClientRequest;
|
|
@@ -24,14 +24,17 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
24
24
|
exports.get = void 0;
|
|
25
25
|
var NodeClientRequest_1 = require("./NodeClientRequest");
|
|
26
26
|
var normalizeClientRequestArgs_1 = require("./utils/normalizeClientRequestArgs");
|
|
27
|
-
function get(protocol,
|
|
27
|
+
function get(protocol, resolver, observer) {
|
|
28
28
|
return function () {
|
|
29
29
|
var args = [];
|
|
30
30
|
for (var _i = 0; _i < arguments.length; _i++) {
|
|
31
31
|
args[_i] = arguments[_i];
|
|
32
32
|
}
|
|
33
33
|
var clientRequestArgs = normalizeClientRequestArgs_1.normalizeClientRequestArgs.apply(void 0, __spreadArray([protocol + ":"], __read(args)));
|
|
34
|
-
var request = new NodeClientRequest_1.NodeClientRequest(clientRequestArgs,
|
|
34
|
+
var request = new NodeClientRequest_1.NodeClientRequest(clientRequestArgs, {
|
|
35
|
+
resolver: resolver,
|
|
36
|
+
observer: observer,
|
|
37
|
+
});
|
|
35
38
|
/**
|
|
36
39
|
* @note https://nodejs.org/api/http.html#httpgetoptions-callback
|
|
37
40
|
* "http.get" sets the method to "GET" and calls "req.end()" automatically.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"http.get.js","sourceRoot":"","sources":["../../../src/interceptors/ClientRequest/http.get.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"http.get.js","sourceRoot":"","sources":["../../../src/interceptors/ClientRequest/http.get.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAEA,yDAAiE;AACjE,iFAG2C;AAE3C,SAAgB,GAAG,CACjB,QAAkB,EAClB,QAAkB,EAClB,QAAkB;IAElB,OAAO;QAAC,cAA0B;aAA1B,UAA0B,EAA1B,qBAA0B,EAA1B,IAA0B;YAA1B,yBAA0B;;QAChC,IAAM,iBAAiB,GAAG,uDAA0B,8BAC/C,QAAQ,MAAG,UACX,IAAI,GACR,CAAA;QACD,IAAM,OAAO,GAAG,IAAI,qCAAiB,CAAC,iBAAiB,EAAE;YACvD,QAAQ,UAAA;YACR,QAAQ,UAAA;SACT,CAAC,CAAA;QAEF;;;WAGG;QACH,OAAO,CAAC,GAAG,EAAE,CAAA;QAEb,OAAO,OAAO,CAAA;IAChB,CAAC,CAAA;AACH,CAAC;AAvBD,kBAuBC"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { ClientRequest } from 'http';
|
|
2
|
-
import {
|
|
2
|
+
import { Observer, Resolver } from '../../createInterceptor';
|
|
3
|
+
import { Protocol } from './NodeClientRequest';
|
|
3
4
|
import { ClientRequestArgs } from './utils/normalizeClientRequestArgs';
|
|
4
|
-
export declare function request(protocol: Protocol,
|
|
5
|
+
export declare function request(protocol: Protocol, resolver: Resolver, observer: Observer): (...args: ClientRequestArgs) => ClientRequest;
|
|
@@ -25,8 +25,8 @@ exports.request = void 0;
|
|
|
25
25
|
var debug_1 = require("debug");
|
|
26
26
|
var NodeClientRequest_1 = require("./NodeClientRequest");
|
|
27
27
|
var normalizeClientRequestArgs_1 = require("./utils/normalizeClientRequestArgs");
|
|
28
|
-
var log = debug_1.debug('http
|
|
29
|
-
function request(protocol,
|
|
28
|
+
var log = debug_1.debug('http.request');
|
|
29
|
+
function request(protocol, resolver, observer) {
|
|
30
30
|
return function () {
|
|
31
31
|
var args = [];
|
|
32
32
|
for (var _i = 0; _i < arguments.length; _i++) {
|
|
@@ -34,7 +34,10 @@ function request(protocol, options) {
|
|
|
34
34
|
}
|
|
35
35
|
log('request call (protocol "%s"):', protocol, args);
|
|
36
36
|
var clientRequestArgs = normalizeClientRequestArgs_1.normalizeClientRequestArgs.apply(void 0, __spreadArray([protocol + ":"], __read(args)));
|
|
37
|
-
return new NodeClientRequest_1.NodeClientRequest(clientRequestArgs,
|
|
37
|
+
return new NodeClientRequest_1.NodeClientRequest(clientRequestArgs, {
|
|
38
|
+
observer: observer,
|
|
39
|
+
resolver: resolver,
|
|
40
|
+
});
|
|
38
41
|
};
|
|
39
42
|
}
|
|
40
43
|
exports.request = request;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"http.request.js","sourceRoot":"","sources":["../../../src/interceptors/ClientRequest/http.request.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAAA,+BAA6B;
|
|
1
|
+
{"version":3,"file":"http.request.js","sourceRoot":"","sources":["../../../src/interceptors/ClientRequest/http.request.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAAA,+BAA6B;AAG7B,yDAAiE;AACjE,iFAG2C;AAE3C,IAAM,GAAG,GAAG,aAAK,CAAC,cAAc,CAAC,CAAA;AAEjC,SAAgB,OAAO,CACrB,QAAkB,EAClB,QAAkB,EAClB,QAAkB;IAElB,OAAO;QAAC,cAA0B;aAA1B,UAA0B,EAA1B,qBAA0B,EAA1B,IAA0B;YAA1B,yBAA0B;;QAChC,GAAG,CAAC,+BAA+B,EAAE,QAAQ,EAAE,IAAI,CAAC,CAAA;QAEpD,IAAM,iBAAiB,GAAG,uDAA0B,8BAC/C,QAAQ,MAAG,UACX,IAAI,GACR,CAAA;QACD,OAAO,IAAI,qCAAiB,CAAC,iBAAiB,EAAE;YAC9C,QAAQ,UAAA;YACR,QAAQ,UAAA;SACT,CAAC,CAAA;IACJ,CAAC,CAAA;AACH,CAAC;AAjBD,0BAiBC"}
|
|
@@ -1,19 +1,9 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
2
|
import http from 'http';
|
|
3
3
|
import https from 'https';
|
|
4
|
-
import {
|
|
5
|
-
|
|
6
|
-
import { AsyncEventEmitter } from '../../utils/AsyncEventEmitter';
|
|
7
|
-
import { Protocol } from './NodeClientRequest';
|
|
8
|
-
export declare type ClientRequestEmitter = AsyncEventEmitter<HttpRequestEventMap>;
|
|
9
|
-
export declare type ClientRequestModules = Map<Protocol, typeof http | typeof https>;
|
|
4
|
+
import { Interceptor } from '../../createInterceptor';
|
|
5
|
+
export declare type RequestModule = typeof http | typeof https;
|
|
10
6
|
/**
|
|
11
|
-
*
|
|
12
|
-
* Such requests include `http.get`, `https.request`, etc.
|
|
7
|
+
* Intercepts requests issued by native "http" and "https" modules.
|
|
13
8
|
*/
|
|
14
|
-
export declare
|
|
15
|
-
static symbol: symbol;
|
|
16
|
-
private modules;
|
|
17
|
-
constructor();
|
|
18
|
-
protected setup(): void;
|
|
19
|
-
}
|
|
9
|
+
export declare const interceptClientRequest: Interceptor;
|