@mswjs/interceptors 0.12.7 → 0.13.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 +64 -15
- package/lib/createInterceptor.d.ts +8 -1
- package/lib/createInterceptor.js.map +1 -1
- package/lib/interceptors/ClientRequest/NodeClientRequest.d.ts +38 -0
- package/lib/interceptors/ClientRequest/NodeClientRequest.js +420 -0
- package/lib/interceptors/ClientRequest/NodeClientRequest.js.map +1 -0
- package/lib/interceptors/ClientRequest/http.get.d.ts +5 -0
- package/lib/interceptors/ClientRequest/http.get.js +47 -0
- package/lib/interceptors/ClientRequest/http.get.js.map +1 -0
- package/lib/interceptors/ClientRequest/http.request.d.ts +5 -0
- package/lib/interceptors/ClientRequest/http.request.js +44 -0
- package/lib/interceptors/ClientRequest/http.request.js.map +1 -0
- package/lib/interceptors/ClientRequest/index.d.ts +5 -1
- package/lib/interceptors/ClientRequest/index.js +50 -84
- package/lib/interceptors/ClientRequest/index.js.map +1 -1
- package/lib/interceptors/ClientRequest/utils/cloneIncomingMessage.d.ts +7 -0
- package/lib/interceptors/ClientRequest/utils/cloneIncomingMessage.js +77 -0
- package/lib/interceptors/ClientRequest/utils/cloneIncomingMessage.js.map +1 -0
- package/lib/interceptors/ClientRequest/utils/getIncomingMessageBody.d.ts +1 -1
- package/lib/interceptors/ClientRequest/utils/getIncomingMessageBody.js +21 -12
- package/lib/interceptors/ClientRequest/utils/getIncomingMessageBody.js.map +1 -1
- package/lib/interceptors/ClientRequest/utils/normalizeClientRequestArgs.d.ts +17 -0
- package/lib/interceptors/ClientRequest/utils/{normalizeHttpRequestParams.js → normalizeClientRequestArgs.js} +65 -39
- package/lib/interceptors/ClientRequest/utils/normalizeClientRequestArgs.js.map +1 -0
- package/lib/interceptors/ClientRequest/utils/normalizeClientRequestEndArgs.d.ts +15 -0
- package/lib/interceptors/ClientRequest/utils/{normalizeHttpRequestEndParams.js → normalizeClientRequestEndArgs.js} +5 -6
- package/lib/interceptors/ClientRequest/utils/normalizeClientRequestEndArgs.js.map +1 -0
- package/lib/interceptors/ClientRequest/utils/normalizeClientRequestWriteArgs.d.ts +13 -0
- package/lib/interceptors/ClientRequest/utils/normalizeClientRequestWriteArgs.js +20 -0
- package/lib/interceptors/ClientRequest/utils/normalizeClientRequestWriteArgs.js.map +1 -0
- package/lib/interceptors/XMLHttpRequest/XMLHttpRequestOverride.d.ts +1 -1
- package/lib/interceptors/XMLHttpRequest/XMLHttpRequestOverride.js +12 -11
- package/lib/interceptors/XMLHttpRequest/XMLHttpRequestOverride.js.map +1 -1
- package/lib/interceptors/fetch/index.js +5 -4
- package/lib/interceptors/fetch/index.js.map +1 -1
- package/lib/remote.js +2 -2
- package/lib/remote.js.map +1 -1
- package/lib/utils/getUrlByRequestOptions.d.ts +5 -4
- package/lib/utils/getUrlByRequestOptions.js.map +1 -1
- package/lib/utils/toIsoResponse.js +2 -2
- package/lib/utils/toIsoResponse.js.map +1 -1
- package/package.json +34 -19
- package/src/createInterceptor.ts +100 -0
- package/src/index.ts +5 -0
- package/src/interceptors/ClientRequest/NodeClientRequest.test.ts +283 -0
- package/src/interceptors/ClientRequest/NodeClientRequest.ts +377 -0
- package/src/interceptors/ClientRequest/http.get.ts +32 -0
- package/src/interceptors/ClientRequest/http.request.ts +29 -0
- package/src/interceptors/ClientRequest/index.ts +61 -0
- package/src/interceptors/ClientRequest/utils/bodyBufferToString.test.ts +16 -0
- package/src/interceptors/ClientRequest/utils/bodyBufferToString.ts +7 -0
- package/src/interceptors/ClientRequest/utils/cloneIncomingMessage.test.ts +20 -0
- package/src/interceptors/ClientRequest/utils/cloneIncomingMessage.ts +41 -0
- package/src/interceptors/ClientRequest/utils/concatChunkToBuffer.test.ts +13 -0
- package/src/interceptors/ClientRequest/utils/concatChunkToBuffer.ts +10 -0
- package/src/interceptors/ClientRequest/utils/getIncomingMessageBody.test.ts +44 -0
- package/src/interceptors/ClientRequest/utils/getIncomingMessageBody.ts +38 -0
- package/src/interceptors/ClientRequest/utils/normalizeClientRequestArgs.test.ts +336 -0
- package/src/interceptors/ClientRequest/utils/normalizeClientRequestArgs.ts +205 -0
- package/src/interceptors/ClientRequest/utils/normalizeClientRequestEndArgs.test.ts +40 -0
- package/src/interceptors/ClientRequest/utils/normalizeClientRequestEndArgs.ts +51 -0
- package/src/interceptors/ClientRequest/utils/normalizeClientRequestWriteArgs.test.ts +35 -0
- package/src/interceptors/ClientRequest/utils/normalizeClientRequestWriteArgs.ts +36 -0
- package/src/interceptors/XMLHttpRequest/XMLHttpRequestOverride.ts +565 -0
- package/src/interceptors/XMLHttpRequest/index.ts +34 -0
- package/src/interceptors/XMLHttpRequest/polyfills/EventPolyfill.ts +51 -0
- package/src/interceptors/XMLHttpRequest/polyfills/ProgressEventPolyfill.ts +17 -0
- package/src/interceptors/XMLHttpRequest/utils/bufferFrom.test.ts +11 -0
- package/src/interceptors/XMLHttpRequest/utils/bufferFrom.ts +16 -0
- package/src/interceptors/XMLHttpRequest/utils/createEvent.test.ts +27 -0
- package/src/interceptors/XMLHttpRequest/utils/createEvent.ts +41 -0
- package/src/interceptors/fetch/index.ts +89 -0
- package/src/presets/browser.ts +8 -0
- package/src/presets/node.ts +8 -0
- package/src/remote.ts +176 -0
- package/src/utils/cloneObject.test.ts +93 -0
- package/src/utils/cloneObject.ts +34 -0
- package/src/utils/getCleanUrl.test.ts +31 -0
- package/src/utils/getCleanUrl.ts +6 -0
- package/src/utils/getRequestOptionsByUrl.ts +29 -0
- package/src/utils/getUrlByRequestOptions.test.ts +140 -0
- package/src/utils/getUrlByRequestOptions.ts +108 -0
- package/src/utils/isObject.test.ts +19 -0
- package/src/utils/isObject.ts +6 -0
- package/src/utils/parseJson.test.ts +9 -0
- package/src/utils/parseJson.ts +12 -0
- package/src/utils/toIsoResponse.test.ts +39 -0
- package/src/utils/toIsoResponse.ts +14 -0
- package/src/utils/uuid.ts +7 -0
- package/lib/interceptors/ClientRequest/ClientRequest.glossary.d.ts +0 -6
- package/lib/interceptors/ClientRequest/ClientRequest.glossary.js +0 -3
- package/lib/interceptors/ClientRequest/ClientRequest.glossary.js.map +0 -1
- package/lib/interceptors/ClientRequest/createClientRequestOverride.d.ts +0 -12
- package/lib/interceptors/ClientRequest/createClientRequestOverride.js +0 -340
- package/lib/interceptors/ClientRequest/createClientRequestOverride.js.map +0 -1
- package/lib/interceptors/ClientRequest/polyfills/SocketPolyfill.d.ts +0 -49
- package/lib/interceptors/ClientRequest/polyfills/SocketPolyfill.js +0 -118
- package/lib/interceptors/ClientRequest/polyfills/SocketPolyfill.js.map +0 -1
- package/lib/interceptors/ClientRequest/utils/inheritRequestHeaders.d.ts +0 -3
- package/lib/interceptors/ClientRequest/utils/inheritRequestHeaders.js +0 -34
- package/lib/interceptors/ClientRequest/utils/inheritRequestHeaders.js.map +0 -1
- package/lib/interceptors/ClientRequest/utils/normalizeHttpRequestEndParams.d.ts +0 -17
- package/lib/interceptors/ClientRequest/utils/normalizeHttpRequestEndParams.js.map +0 -1
- package/lib/interceptors/ClientRequest/utils/normalizeHttpRequestParams.d.ts +0 -11
- package/lib/interceptors/ClientRequest/utils/normalizeHttpRequestParams.js.map +0 -1
|
@@ -0,0 +1 @@
|
|
|
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;IAAuC,qCAAa;IAuBlD,2BACE,EAA4D,EAC5D,OAA0B;YAD1B,KAAA,aAA4D,EAA3D,GAAG,QAAA,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AAM;YACnB,OAAO,SAAA;YACP,IAAI,MAAA;SACL,CAAA;QAED,IAAI,CAAC,GAAG,CAAC,0CAA0C,EAAE,iBAAiB,CAAC,CAAA;QACvE,OAAO,iBAAiB,CAAA;IAC1B,CAAC;IAnVD;;;OAGG;IACI,oCAAkB,GAAG,CAAC,WAAW,EAAE,cAAc,EAAE,YAAY,CAAC,CAAA;IAgVzE,wBAAC;CAAA,AArVD,CAAuC,oBAAa,GAqVnD;AArVY,8CAAiB"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { ClientRequest } from 'node:http';
|
|
2
|
+
import { Observer, Resolver } from '../../createInterceptor';
|
|
3
|
+
import { Protocol } from './NodeClientRequest';
|
|
4
|
+
import { ClientRequestArgs } from './utils/normalizeClientRequestArgs';
|
|
5
|
+
export declare function get(protocol: Protocol, resolver: Resolver, observer: Observer): (...args: ClientRequestArgs) => ClientRequest;
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __read = (this && this.__read) || function (o, n) {
|
|
3
|
+
var m = typeof Symbol === "function" && o[Symbol.iterator];
|
|
4
|
+
if (!m) return o;
|
|
5
|
+
var i = m.call(o), r, ar = [], e;
|
|
6
|
+
try {
|
|
7
|
+
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
|
|
8
|
+
}
|
|
9
|
+
catch (error) { e = { error: error }; }
|
|
10
|
+
finally {
|
|
11
|
+
try {
|
|
12
|
+
if (r && !r.done && (m = i["return"])) m.call(i);
|
|
13
|
+
}
|
|
14
|
+
finally { if (e) throw e.error; }
|
|
15
|
+
}
|
|
16
|
+
return ar;
|
|
17
|
+
};
|
|
18
|
+
var __spreadArray = (this && this.__spreadArray) || function (to, from) {
|
|
19
|
+
for (var i = 0, il = from.length, j = to.length; i < il; i++, j++)
|
|
20
|
+
to[j] = from[i];
|
|
21
|
+
return to;
|
|
22
|
+
};
|
|
23
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
24
|
+
exports.get = void 0;
|
|
25
|
+
var NodeClientRequest_1 = require("./NodeClientRequest");
|
|
26
|
+
var normalizeClientRequestArgs_1 = require("./utils/normalizeClientRequestArgs");
|
|
27
|
+
function get(protocol, resolver, observer) {
|
|
28
|
+
return function () {
|
|
29
|
+
var args = [];
|
|
30
|
+
for (var _i = 0; _i < arguments.length; _i++) {
|
|
31
|
+
args[_i] = arguments[_i];
|
|
32
|
+
}
|
|
33
|
+
var clientRequestArgs = normalizeClientRequestArgs_1.normalizeClientRequestArgs.apply(void 0, __spreadArray([protocol + ":"], __read(args)));
|
|
34
|
+
var request = new NodeClientRequest_1.NodeClientRequest(clientRequestArgs, {
|
|
35
|
+
resolver: resolver,
|
|
36
|
+
observer: observer,
|
|
37
|
+
});
|
|
38
|
+
/**
|
|
39
|
+
* @note https://nodejs.org/api/http.html#httpgetoptions-callback
|
|
40
|
+
* "http.get" sets the method to "GET" and calls "req.end()" automatically.
|
|
41
|
+
*/
|
|
42
|
+
request.end();
|
|
43
|
+
return request;
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
exports.get = get;
|
|
47
|
+
//# sourceMappingURL=http.get.js.map
|
|
@@ -0,0 +1 @@
|
|
|
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"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { ClientRequest } from 'http';
|
|
2
|
+
import { Observer, Resolver } from '../../createInterceptor';
|
|
3
|
+
import { Protocol } from './NodeClientRequest';
|
|
4
|
+
import { ClientRequestArgs } from './utils/normalizeClientRequestArgs';
|
|
5
|
+
export declare function request(protocol: Protocol, resolver: Resolver, observer: Observer): (...args: ClientRequestArgs) => ClientRequest;
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __read = (this && this.__read) || function (o, n) {
|
|
3
|
+
var m = typeof Symbol === "function" && o[Symbol.iterator];
|
|
4
|
+
if (!m) return o;
|
|
5
|
+
var i = m.call(o), r, ar = [], e;
|
|
6
|
+
try {
|
|
7
|
+
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
|
|
8
|
+
}
|
|
9
|
+
catch (error) { e = { error: error }; }
|
|
10
|
+
finally {
|
|
11
|
+
try {
|
|
12
|
+
if (r && !r.done && (m = i["return"])) m.call(i);
|
|
13
|
+
}
|
|
14
|
+
finally { if (e) throw e.error; }
|
|
15
|
+
}
|
|
16
|
+
return ar;
|
|
17
|
+
};
|
|
18
|
+
var __spreadArray = (this && this.__spreadArray) || function (to, from) {
|
|
19
|
+
for (var i = 0, il = from.length, j = to.length; i < il; i++, j++)
|
|
20
|
+
to[j] = from[i];
|
|
21
|
+
return to;
|
|
22
|
+
};
|
|
23
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
24
|
+
exports.request = void 0;
|
|
25
|
+
var debug_1 = require("debug");
|
|
26
|
+
var NodeClientRequest_1 = require("./NodeClientRequest");
|
|
27
|
+
var normalizeClientRequestArgs_1 = require("./utils/normalizeClientRequestArgs");
|
|
28
|
+
var log = debug_1.debug('http.request');
|
|
29
|
+
function request(protocol, resolver, observer) {
|
|
30
|
+
return function () {
|
|
31
|
+
var args = [];
|
|
32
|
+
for (var _i = 0; _i < arguments.length; _i++) {
|
|
33
|
+
args[_i] = arguments[_i];
|
|
34
|
+
}
|
|
35
|
+
log('intercepted request:', args);
|
|
36
|
+
var clientRequestArgs = normalizeClientRequestArgs_1.normalizeClientRequestArgs.apply(void 0, __spreadArray([protocol + ":"], __read(args)));
|
|
37
|
+
return new NodeClientRequest_1.NodeClientRequest(clientRequestArgs, {
|
|
38
|
+
observer: observer,
|
|
39
|
+
resolver: resolver,
|
|
40
|
+
});
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
exports.request = request;
|
|
44
|
+
//# sourceMappingURL=http.request.js.map
|
|
@@ -0,0 +1 @@
|
|
|
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,sBAAsB,EAAE,IAAI,CAAC,CAAA;QAEjC,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,5 +1,9 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
import http from 'http';
|
|
3
|
+
import https from 'https';
|
|
1
4
|
import { Interceptor } from '../../createInterceptor';
|
|
5
|
+
export declare type RequestModule = typeof http | typeof https;
|
|
2
6
|
/**
|
|
3
|
-
* Intercepts requests issued by native
|
|
7
|
+
* Intercepts requests issued by native "http" and "https" modules.
|
|
4
8
|
*/
|
|
5
9
|
export declare const interceptClientRequest: Interceptor;
|
|
@@ -1,4 +1,15 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __values = (this && this.__values) || function(o) {
|
|
3
|
+
var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
|
|
4
|
+
if (m) return m.call(o);
|
|
5
|
+
if (o && typeof o.length === "number") return {
|
|
6
|
+
next: function () {
|
|
7
|
+
if (o && i >= o.length) o = void 0;
|
|
8
|
+
return { value: o && o[i++], done: !o };
|
|
9
|
+
}
|
|
10
|
+
};
|
|
11
|
+
throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
|
|
12
|
+
};
|
|
2
13
|
var __read = (this && this.__read) || function (o, n) {
|
|
3
14
|
var m = typeof Symbol === "function" && o[Symbol.iterator];
|
|
4
15
|
if (!m) return o;
|
|
@@ -15,101 +26,56 @@ var __read = (this && this.__read) || function (o, n) {
|
|
|
15
26
|
}
|
|
16
27
|
return ar;
|
|
17
28
|
};
|
|
18
|
-
var __spreadArray = (this && this.__spreadArray) || function (to, from) {
|
|
19
|
-
for (var i = 0, il = from.length, j = to.length; i < il; i++, j++)
|
|
20
|
-
to[j] = from[i];
|
|
21
|
-
return to;
|
|
22
|
-
};
|
|
23
|
-
var __values = (this && this.__values) || function(o) {
|
|
24
|
-
var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
|
|
25
|
-
if (m) return m.call(o);
|
|
26
|
-
if (o && typeof o.length === "number") return {
|
|
27
|
-
next: function () {
|
|
28
|
-
if (o && i >= o.length) o = void 0;
|
|
29
|
-
return { value: o && o[i++], done: !o };
|
|
30
|
-
}
|
|
31
|
-
};
|
|
32
|
-
throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
|
|
33
|
-
};
|
|
34
29
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
35
30
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
36
31
|
};
|
|
37
32
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
38
33
|
exports.interceptClientRequest = void 0;
|
|
34
|
+
var debug_1 = require("debug");
|
|
39
35
|
var http_1 = __importDefault(require("http"));
|
|
40
36
|
var https_1 = __importDefault(require("https"));
|
|
41
|
-
var
|
|
42
|
-
var
|
|
43
|
-
|
|
44
|
-
// so it can be mutated during runtime, affecting any subsequent calls.
|
|
45
|
-
var pureClientRequest;
|
|
46
|
-
function handleClientRequest(protocol, pureMethod, args, observer, resolver) {
|
|
47
|
-
// The first time we execute this, I'll save the original ClientRequest.
|
|
48
|
-
// This because is used to restore the dafault one later
|
|
49
|
-
if (!pureClientRequest) {
|
|
50
|
-
pureClientRequest = http_1.default.ClientRequest;
|
|
51
|
-
}
|
|
52
|
-
var ClientRequestOverride = createClientRequestOverride_1.createClientRequestOverride({
|
|
53
|
-
defaultProtocol: protocol + ":",
|
|
54
|
-
pureClientRequest: pureClientRequest,
|
|
55
|
-
pureMethod: pureMethod,
|
|
56
|
-
observer: observer,
|
|
57
|
-
resolver: resolver,
|
|
58
|
-
});
|
|
59
|
-
debug('new ClientRequestOverride (origin: %s)', protocol);
|
|
60
|
-
// @ts-expect-error Variable call signature.
|
|
61
|
-
return new (ClientRequestOverride.bind.apply(ClientRequestOverride, __spreadArray([void 0], __read(args))))();
|
|
62
|
-
}
|
|
37
|
+
var http_get_1 = require("./http.get");
|
|
38
|
+
var http_request_1 = require("./http.request");
|
|
39
|
+
var log = debug_1.debug('http override');
|
|
63
40
|
/**
|
|
64
|
-
* Intercepts requests issued by native
|
|
41
|
+
* Intercepts requests issued by native "http" and "https" modules.
|
|
65
42
|
*/
|
|
66
43
|
var interceptClientRequest = function (observer, resolver) {
|
|
44
|
+
var e_1, _a;
|
|
67
45
|
var pureModules = new Map();
|
|
68
|
-
var modules = [
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
46
|
+
var modules = [
|
|
47
|
+
['http', http_1.default],
|
|
48
|
+
['https', https_1.default],
|
|
49
|
+
];
|
|
50
|
+
try {
|
|
51
|
+
for (var modules_1 = __values(modules), modules_1_1 = modules_1.next(); !modules_1_1.done; modules_1_1 = modules_1.next()) {
|
|
52
|
+
var _b = __read(modules_1_1.value, 2), protocol = _b[0], requestModule = _b[1];
|
|
53
|
+
log('patching the "%s" module...', protocol);
|
|
54
|
+
pureModules.set(protocol, {
|
|
55
|
+
module: requestModule,
|
|
56
|
+
request: requestModule.request,
|
|
57
|
+
get: requestModule.get,
|
|
58
|
+
});
|
|
59
|
+
// @ts-ignore Call signature overloads are incompatible.
|
|
60
|
+
requestModule.request =
|
|
61
|
+
// Force a line-break to prevent ignoring the "request" call.
|
|
62
|
+
http_request_1.request(protocol, resolver, observer);
|
|
63
|
+
// @ts-ignore Call signature overloads are incompatible.
|
|
64
|
+
requestModule.get =
|
|
65
|
+
// Force a line-break to prevent ignoring the "get" call.
|
|
66
|
+
http_get_1.get(protocol, resolver, observer);
|
|
82
67
|
}
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
return handleClientRequest(protocol, proxiedOriginalRequest.bind(requestModule), args, observer, resolver);
|
|
92
|
-
};
|
|
93
|
-
// @ts-ignore
|
|
94
|
-
requestModule.get = function getOverride() {
|
|
95
|
-
var args = [];
|
|
96
|
-
for (var _i = 0; _i < arguments.length; _i++) {
|
|
97
|
-
args[_i] = arguments[_i];
|
|
98
|
-
}
|
|
99
|
-
debug('%s.get call', protocol);
|
|
100
|
-
var req = handleClientRequest(protocol, originalGet.bind(requestModule), args, observer, resolver);
|
|
101
|
-
req.end();
|
|
102
|
-
return req;
|
|
103
|
-
};
|
|
104
|
-
pureModules.set(protocol, {
|
|
105
|
-
module: requestModule,
|
|
106
|
-
request: originalRequest,
|
|
107
|
-
get: originalGet,
|
|
108
|
-
});
|
|
109
|
-
});
|
|
68
|
+
}
|
|
69
|
+
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
70
|
+
finally {
|
|
71
|
+
try {
|
|
72
|
+
if (modules_1_1 && !modules_1_1.done && (_a = modules_1.return)) _a.call(modules_1);
|
|
73
|
+
}
|
|
74
|
+
finally { if (e_1) throw e_1.error; }
|
|
75
|
+
}
|
|
110
76
|
return function () {
|
|
111
|
-
var
|
|
112
|
-
|
|
77
|
+
var e_2, _a;
|
|
78
|
+
log('done, restoring modules...');
|
|
113
79
|
try {
|
|
114
80
|
for (var _b = __values(pureModules.values()), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
115
81
|
var requestModule = _c.value;
|
|
@@ -117,12 +83,12 @@ var interceptClientRequest = function (observer, resolver) {
|
|
|
117
83
|
requestModule.module.request = requestModule.request;
|
|
118
84
|
}
|
|
119
85
|
}
|
|
120
|
-
catch (
|
|
86
|
+
catch (e_2_1) { e_2 = { error: e_2_1 }; }
|
|
121
87
|
finally {
|
|
122
88
|
try {
|
|
123
89
|
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
|
|
124
90
|
}
|
|
125
|
-
finally { if (
|
|
91
|
+
finally { if (e_2) throw e_2.error; }
|
|
126
92
|
}
|
|
127
93
|
pureModules.clear();
|
|
128
94
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/interceptors/ClientRequest/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/interceptors/ClientRequest/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;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GAAG,aAAa,CAAC,OAAO,CAAA;aACrD;;;;;;;;;QAED,WAAW,CAAC,KAAK,EAAE,CAAA;IACrB,CAAC,CAAA;AACH,CAAC,CAAA;AArCY,QAAA,sBAAsB,0BAqClC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
import { IncomingMessage } from 'http';
|
|
3
|
+
export declare const IS_CLONE: unique symbol;
|
|
4
|
+
export interface ClonedIncomingMessage extends IncomingMessage {
|
|
5
|
+
[IS_CLONE]: boolean;
|
|
6
|
+
}
|
|
7
|
+
export declare function cloneIncomingMessage(message: IncomingMessage): ClonedIncomingMessage;
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __assign = (this && this.__assign) || function () {
|
|
3
|
+
__assign = Object.assign || function(t) {
|
|
4
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
5
|
+
s = arguments[i];
|
|
6
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
7
|
+
t[p] = s[p];
|
|
8
|
+
}
|
|
9
|
+
return t;
|
|
10
|
+
};
|
|
11
|
+
return __assign.apply(this, arguments);
|
|
12
|
+
};
|
|
13
|
+
var __read = (this && this.__read) || function (o, n) {
|
|
14
|
+
var m = typeof Symbol === "function" && o[Symbol.iterator];
|
|
15
|
+
if (!m) return o;
|
|
16
|
+
var i = m.call(o), r, ar = [], e;
|
|
17
|
+
try {
|
|
18
|
+
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
|
|
19
|
+
}
|
|
20
|
+
catch (error) { e = { error: error }; }
|
|
21
|
+
finally {
|
|
22
|
+
try {
|
|
23
|
+
if (r && !r.done && (m = i["return"])) m.call(i);
|
|
24
|
+
}
|
|
25
|
+
finally { if (e) throw e.error; }
|
|
26
|
+
}
|
|
27
|
+
return ar;
|
|
28
|
+
};
|
|
29
|
+
var __spreadArray = (this && this.__spreadArray) || function (to, from) {
|
|
30
|
+
for (var i = 0, il = from.length, j = to.length; i < il; i++, j++)
|
|
31
|
+
to[j] = from[i];
|
|
32
|
+
return to;
|
|
33
|
+
};
|
|
34
|
+
var __values = (this && this.__values) || function(o) {
|
|
35
|
+
var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
|
|
36
|
+
if (m) return m.call(o);
|
|
37
|
+
if (o && typeof o.length === "number") return {
|
|
38
|
+
next: function () {
|
|
39
|
+
if (o && i >= o.length) o = void 0;
|
|
40
|
+
return { value: o && o[i++], done: !o };
|
|
41
|
+
}
|
|
42
|
+
};
|
|
43
|
+
throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
|
|
44
|
+
};
|
|
45
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
46
|
+
exports.cloneIncomingMessage = exports.IS_CLONE = void 0;
|
|
47
|
+
var stream_1 = require("stream");
|
|
48
|
+
exports.IS_CLONE = Symbol('isClone');
|
|
49
|
+
function cloneIncomingMessage(message) {
|
|
50
|
+
var e_1, _a;
|
|
51
|
+
var stream = message.pipe(new stream_1.PassThrough());
|
|
52
|
+
var properties = __spreadArray(__spreadArray([], __read(Object.getOwnPropertyNames(message))), __read(Object.getOwnPropertySymbols(message)));
|
|
53
|
+
try {
|
|
54
|
+
for (var properties_1 = __values(properties), properties_1_1 = properties_1.next(); !properties_1_1.done; properties_1_1 = properties_1.next()) {
|
|
55
|
+
var propertyName = properties_1_1.value;
|
|
56
|
+
if (stream.hasOwnProperty(propertyName)) {
|
|
57
|
+
continue;
|
|
58
|
+
}
|
|
59
|
+
var propertyDescriptor = Object.getOwnPropertyDescriptor(message, propertyName);
|
|
60
|
+
Object.defineProperty(stream, propertyName, __assign(__assign({}, propertyDescriptor), { value: message[propertyName] }));
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
64
|
+
finally {
|
|
65
|
+
try {
|
|
66
|
+
if (properties_1_1 && !properties_1_1.done && (_a = properties_1.return)) _a.call(properties_1);
|
|
67
|
+
}
|
|
68
|
+
finally { if (e_1) throw e_1.error; }
|
|
69
|
+
}
|
|
70
|
+
Object.defineProperty(stream, exports.IS_CLONE, {
|
|
71
|
+
enumerable: true,
|
|
72
|
+
value: true,
|
|
73
|
+
});
|
|
74
|
+
return stream;
|
|
75
|
+
}
|
|
76
|
+
exports.cloneIncomingMessage = cloneIncomingMessage;
|
|
77
|
+
//# sourceMappingURL=cloneIncomingMessage.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cloneIncomingMessage.js","sourceRoot":"","sources":["../../../../src/interceptors/ClientRequest/utils/cloneIncomingMessage.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,iCAAoC;AAEvB,QAAA,QAAQ,GAAG,MAAM,CAAC,SAAS,CAAC,CAAA;AAMzC,SAAgB,oBAAoB,CAClC,OAAwB;;IAExB,IAAM,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,IAAI,oBAAW,EAAE,CAAC,CAAA;IAC9C,IAAM,UAAU,GAAG,uCACd,MAAM,CAAC,mBAAmB,CAAC,OAAO,CAAC,WACnC,MAAM,CAAC,qBAAqB,CAAC,OAAO,CAAC,EACT,CAAA;;QAEjC,KAA2B,IAAA,eAAA,SAAA,UAAU,CAAA,sCAAA,8DAAE;YAAlC,IAAM,YAAY,uBAAA;YACrB,IAAI,MAAM,CAAC,cAAc,CAAC,YAAY,CAAC,EAAE;gBACvC,SAAQ;aACT;YAED,IAAM,kBAAkB,GAAG,MAAM,CAAC,wBAAwB,CACxD,OAAO,EACP,YAAY,CACb,CAAA;YAED,MAAM,CAAC,cAAc,CAAC,MAAM,EAAE,YAAY,wBACrC,kBAAkB,KACrB,KAAK,EAAE,OAAO,CAAC,YAAY,CAAC,IAC5B,CAAA;SACH;;;;;;;;;IAED,MAAM,CAAC,cAAc,CAAC,MAAM,EAAE,gBAAQ,EAAE;QACtC,UAAU,EAAE,IAAI;QAChB,KAAK,EAAE,IAAI;KACZ,CAAC,CAAA;IAEF,OAAO,MAA0C,CAAA;AACnD,CAAC;AA/BD,oDA+BC"}
|
|
@@ -20,23 +20,32 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
20
20
|
};
|
|
21
21
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
22
22
|
exports.getIncomingMessageBody = void 0;
|
|
23
|
+
var debug_1 = require("debug");
|
|
24
|
+
var stream_1 = require("stream");
|
|
23
25
|
var zlib = __importStar(require("zlib"));
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
var stream = res;
|
|
27
|
-
if (res.headers['content-encoding'] === 'gzip') {
|
|
28
|
-
stream = res.pipe(zlib.createGunzip());
|
|
29
|
-
}
|
|
26
|
+
var log = debug_1.debug('http getIncomingMessageBody');
|
|
27
|
+
function getIncomingMessageBody(response) {
|
|
30
28
|
return new Promise(function (resolve, reject) {
|
|
29
|
+
log('cloning the original response...');
|
|
30
|
+
// Pipe the original response to support non-clone
|
|
31
|
+
// "response" input. No need to clone the response,
|
|
32
|
+
// as we always have access to the full "response" input,
|
|
33
|
+
// either a clone or an original one (in tests).
|
|
34
|
+
var responseClone = response.pipe(new stream_1.PassThrough());
|
|
35
|
+
var stream = response.headers['content-encoding'] === 'gzip'
|
|
36
|
+
? responseClone.pipe(zlib.createGunzip())
|
|
37
|
+
: responseClone;
|
|
38
|
+
var encoding = response.readableEncoding || 'utf8';
|
|
39
|
+
stream.setEncoding(encoding);
|
|
40
|
+
log('using encoding:', encoding);
|
|
41
|
+
stream.once('data', function (responseBody) {
|
|
42
|
+
log('response body read:', responseBody);
|
|
43
|
+
resolve(responseBody);
|
|
44
|
+
});
|
|
31
45
|
stream.once('error', function (error) {
|
|
32
|
-
|
|
46
|
+
log('error while reading response body:', error);
|
|
33
47
|
reject(error);
|
|
34
48
|
});
|
|
35
|
-
stream.on('data', function (chunk) { return (responseBody += chunk); });
|
|
36
|
-
stream.once('end', function () {
|
|
37
|
-
stream.removeAllListeners();
|
|
38
|
-
resolve(responseBody);
|
|
39
|
-
});
|
|
40
49
|
});
|
|
41
50
|
}
|
|
42
51
|
exports.getIncomingMessageBody = getIncomingMessageBody;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getIncomingMessageBody.js","sourceRoot":"","sources":["../../../../src/interceptors/ClientRequest/utils/getIncomingMessageBody.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"getIncomingMessageBody.js","sourceRoot":"","sources":["../../../../src/interceptors/ClientRequest/utils/getIncomingMessageBody.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAAA,+BAA6B;AAE7B,iCAAoC;AACpC,yCAA4B;AAE5B,IAAM,GAAG,GAAG,aAAK,CAAC,6BAA6B,CAAC,CAAA;AAEhD,SAAgB,sBAAsB,CACpC,QAAyB;IAEzB,OAAO,IAAI,OAAO,CAAC,UAAC,OAAO,EAAE,MAAM;QACjC,GAAG,CAAC,kCAAkC,CAAC,CAAA;QAEvC,kDAAkD;QAClD,mDAAmD;QACnD,yDAAyD;QACzD,gDAAgD;QAChD,IAAM,aAAa,GAAG,QAAQ,CAAC,IAAI,CAAC,IAAI,oBAAW,EAAE,CAAC,CAAA;QACtD,IAAM,MAAM,GACV,QAAQ,CAAC,OAAO,CAAC,kBAAkB,CAAC,KAAK,MAAM;YAC7C,CAAC,CAAC,aAAa,CAAC,IAAI,CAAC,IAAI,CAAC,YAAY,EAAE,CAAC;YACzC,CAAC,CAAC,aAAa,CAAA;QAEnB,IAAM,QAAQ,GAAG,QAAQ,CAAC,gBAAgB,IAAI,MAAM,CAAA;QACpD,MAAM,CAAC,WAAW,CAAC,QAAQ,CAAC,CAAA;QAC5B,GAAG,CAAC,iBAAiB,EAAE,QAAQ,CAAC,CAAA;QAEhC,MAAM,CAAC,IAAI,CAAC,MAAM,EAAE,UAAC,YAAY;YAC/B,GAAG,CAAC,qBAAqB,EAAE,YAAY,CAAC,CAAA;YACxC,OAAO,CAAC,YAAY,CAAC,CAAA;QACvB,CAAC,CAAC,CAAA;QAEF,MAAM,CAAC,IAAI,CAAC,OAAO,EAAE,UAAC,KAAK;YACzB,GAAG,CAAC,oCAAoC,EAAE,KAAK,CAAC,CAAA;YAChD,MAAM,CAAC,KAAK,CAAC,CAAA;QACf,CAAC,CAAC,CAAA;IACJ,CAAC,CAAC,CAAA;AACJ,CAAC;AA9BD,wDA8BC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
import { IncomingMessage } from 'http';
|
|
3
|
+
import { RequestOptions } from 'https';
|
|
4
|
+
import { Url as LegacyURL } from 'url';
|
|
5
|
+
import { ResolvedRequestOptions } from '../../../utils/getUrlByRequestOptions';
|
|
6
|
+
export declare type HttpRequestCallback = (response: IncomingMessage) => void;
|
|
7
|
+
export declare type ClientRequestArgs = [string | URL | LegacyURL, HttpRequestCallback?] | [string | URL | LegacyURL, RequestOptions, HttpRequestCallback?] | [RequestOptions, HttpRequestCallback?];
|
|
8
|
+
export declare type NormalizedClientRequestArgs = [
|
|
9
|
+
url: URL,
|
|
10
|
+
options: ResolvedRequestOptions,
|
|
11
|
+
callback?: HttpRequestCallback
|
|
12
|
+
];
|
|
13
|
+
/**
|
|
14
|
+
* Normalizes parameters given to a `http.request` call
|
|
15
|
+
* so it always has a `URL` and `RequestOptions`.
|
|
16
|
+
*/
|
|
17
|
+
export declare function normalizeClientRequestArgs(defaultProtocol: string, ...args: ClientRequestArgs): NormalizedClientRequestArgs;
|