node-tdd 6.0.3 → 6.1.0
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.
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export default (interceptor) => {
|
|
2
|
+
const result = [];
|
|
3
|
+
for (let i = 0; i < interceptor.rawHeaders.length; i += 2) {
|
|
4
|
+
const name = interceptor.rawHeaders[i];
|
|
5
|
+
let value = interceptor.rawHeaders[i + 1];
|
|
6
|
+
if (name.toLowerCase() === 'content-length') {
|
|
7
|
+
value = interceptor.body[
|
|
8
|
+
interceptor.body instanceof Buffer ? 'byteLength' : 'length'
|
|
9
|
+
].toString();
|
|
10
|
+
}
|
|
11
|
+
result.push(name, value);
|
|
12
|
+
}
|
|
13
|
+
return result;
|
|
14
|
+
};
|
|
@@ -14,14 +14,14 @@ import nockMock from './request-recorder/nock-mock.js';
|
|
|
14
14
|
import healSqs from './request-recorder/heal-sqs.js';
|
|
15
15
|
import applyModifiers from './request-recorder/apply-modifiers.js';
|
|
16
16
|
import requestInjector from './request-recorder/request-injector.js';
|
|
17
|
-
|
|
17
|
+
import updateAndRestoreModifiers from './request-recorder/update-and-restore-modifiers.js';
|
|
18
|
+
import healResponseHeaders from './request-recorder/heal-response-headers.js';
|
|
18
19
|
import {
|
|
19
20
|
buildKey,
|
|
20
21
|
tryParseJson,
|
|
21
22
|
nullAsString,
|
|
22
23
|
rewriteHeaders
|
|
23
24
|
} from './request-recorder/util.js';
|
|
24
|
-
import updateAndRestoreModifiers from './request-recorder/update-and-restore-modifiers.js';
|
|
25
25
|
|
|
26
26
|
const nockBack = nock.back;
|
|
27
27
|
const nockRecorder = nock.recorder;
|
|
@@ -231,6 +231,16 @@ export default (opts) => {
|
|
|
231
231
|
...rewriteHeaders(pendingMocks[idx].record.reqheaders)
|
|
232
232
|
};
|
|
233
233
|
pendingMocks[idx].record.reqheaders = rewriteHeaders(reqheaders, overwriteHeaders);
|
|
234
|
+
|
|
235
|
+
// heal response headers
|
|
236
|
+
const newHeaders = healResponseHeaders(interceptor);
|
|
237
|
+
if (newHeaders.length === 0) {
|
|
238
|
+
delete pendingMocks[idx].record.rawHeaders;
|
|
239
|
+
} else {
|
|
240
|
+
pendingMocks[idx].record.rawHeaders = newHeaders;
|
|
241
|
+
}
|
|
242
|
+
// eslint-disable-next-line no-param-reassign
|
|
243
|
+
interceptor.rawHeaders = newHeaders; // ensure response handled correctly
|
|
234
244
|
}
|
|
235
245
|
|
|
236
246
|
if (anyFlagPresent(['magic', 'response'])) {
|